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.
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)
# File lib/taskjuggler/Interval.rb, line 116 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
Return the duration of the TimeInterval.
# File lib/taskjuggler/Interval.rb, line 144 def duration @end - @start end
Turn the TimeInterval into a human readable form.
# File lib/taskjuggler/Interval.rb, line 149 def to_s @start.to_s + ' - ' + @end.to_s end
Generated with the Darkfish Rdoc Generator 2.