class TaskJuggler::TimeInterval
The TimeInterval
class provides objects that model a time interval. The start end end time are represented as seconds after Jan 1, 1970. The start is part of the interval, the end is not.
Attributes
Public Class Methods
Source
# File lib/taskjuggler/Interval.rb, line 119 def initialize(*args) if args.length == 1 if args[0].is_a?(TjTime) # Just one argument, a date super(args[0], args[0]) elsif args[0].is_a?(TimeInterval) # Just one argument, a TimeInterval super(args[0].start, args[0].end) else raise ArgumentError, "Illegal argument 1: #{args[0].class}" end elsif args.length == 2 # Two arguments, a start and end date unless args[0].is_a?(TjTime) raise ArgumentError, "Interval start must be a date, not a " + "#{args[0].class}" end unless args[1].is_a?(TjTime) raise ArgumentError, "Interval end must be a date, not a" + "#{args[1].class}" end super(args[0], args[1]) else raise ArgumentError, "Too many arguments: #{args.length}" end end
Create a new TimeInterval
. args can be three different kind of arguments.
a and b should be TjTime
objects.
TimeInterval.new(a, b)
| -> Interval(a, b) TimeInterval.new(a)
| -> Interval(a, a) TimeInterval.new(iv)
| -> Interval(iv.start, iv.end)
Calls superclass method
TaskJuggler::Interval::new
Public Instance Methods
Source
# File lib/taskjuggler/Interval.rb, line 147 def duration @end - @start end
Return the duration of the TimeInterval
.
Source
# File lib/taskjuggler/Interval.rb, line 152 def to_s @start.to_s + ' - ' + @end.to_s end
Turn the TimeInterval
into a human readable form.