class TaskJuggler::ScoreboardInterval

This class describes an interval of a scoreboard. The start and end of the interval are stored as indexes but can always be converted back to TjTime objects if needed.

Attributes

sbStart[R]
slotDuration[R]

Public Class Methods

new(*args) click to toggle source

Create a new ScoreboardInterval. args can be three different kind of arguments.

sbStart must be a TjTime of the scoreboard start slotDuration must be the duration of the scoreboard slots in seconds a and b should be TjTime or Fixnum objects that describe the start and end time or index of the interval.

TaskJuggler::TimeInterval.new TaskJuggler::TimeInterval.new(sbStart, slotDuration, a) TaskJuggler::TimeInterval.new(sbStart, slotDuration, a, b)

Calls superclass method TaskJuggler::Interval.new
# File lib/taskjuggler/Interval.rb, line 175
def initialize(*args)
  case args.length
  when 1
    # If there is only one argument, it must be a ScoreboardInterval.
    if args[0].is_a?(ScoreboardInterval)
      @sbStart = args[0].sbStart
      @slotDuration = args[0].slotDuration
      # Just one argument, a TimeInterval
      super(args[0].start, args[0].end)
    else
      raise ArgumentError, "Illegal argument 1: #{args[0].class}"
    end
  when 3
    @sbStart = args[0]
    @slotDuration = args[1]
    # If the third argument is a date we convert it to a scoreboard index.
    args[2] = dateToIndex(args[2]) if args[2].is_a?(TjTime)

    if args[2].is_a?(Fixnum) || args[2].is_a?(Bignum)
      super(args[2], args[2])
    else
      raise ArgumentError, "Illegal argument 3: #{args[0].class}"
    end
  when 4
    @sbStart = args[0]
    @slotDuration = args[1]
    # If the third and forth arguments are a date we convert them to a
    # scoreboard index.
    args[2] = dateToIndex(args[2]) if args[2].is_a?(TjTime)
    args[3] = dateToIndex(args[3]) if args[3].is_a?(TjTime)

    if !(args[2].is_a?(Fixnum) || args[2].is_a?(Bignum))
      raise ArgumentError, "Interval start must be an index or TjTime, " +
            "not a #{args[2].class}"
    end
    if !(args[3].is_a?(Fixnum) || args[3].is_a?(Bignum))
      raise ArgumentError, "Interval end must be an index or TjTime, " +
            "not a #{args[3].class}"
    end
    super(args[2], args[3])
  else
    raise ArgumentError, "Wrong number of arguments: #{args.length}"
  end

  unless @sbStart.is_a?(TjTime)
    raise ArgumentError, "sbStart must be a TjTime object, not a" +
          "#{@sbStart.class}"
  end
  unless @slotDuration.is_a?(Fixnum)
    raise ArgumentError, "slotDuration must be a Fixnum, not a " +
          "#{@slotDuration.class}"
  end

end

Public Instance Methods

duration() click to toggle source

Return the duration of the ScoreboardInterval.

# File lib/taskjuggler/Interval.rb, line 269
def duration
  indexToDate(@end) - indexToDate(@start)
end
end(=(arg)) click to toggle source

Assign the start of the interval. arg can be a Fixnum, Bignum or TjTime object.

# File lib/taskjuggler/Interval.rb, line 246
def end=(arg)
  case arg
  when Fixnum
  when Bignum
    @end = arg
  when TjTime
    @end = dateToIndex(arg)
  else
    raise ArgumentError, "Unsupported class #{arg.class}"
  end
end
endDate() click to toggle source

Return the interval end as TjTime object.

# File lib/taskjuggler/Interval.rb, line 264
def endDate
  indexToDate(@end)
end
start=(arg) click to toggle source

Assign the start of the interval. arg can be a Fixnum, Bignum or TjTime object.

# File lib/taskjuggler/Interval.rb, line 232
def start=(arg)
  case arg
  when Fixnum
  when Bignum
    @start = arg
  when TjTime
    @start = dateToIndex(arg)
  else
    raise ArgumentError, "Unsupported class #{arg.class}"
  end
end
startDate() click to toggle source

Return the interval start as TjTime object.

# File lib/taskjuggler/Interval.rb, line 259
def startDate
  indexToDate(@start)
end
to_s() click to toggle source

Turn the ScoreboardInterval into a human readable form.

# File lib/taskjuggler/Interval.rb, line 274
def to_s
  indexToDate(@start).to_s + ' - ' + indexToDate(@end).to_s
end