class Biz::Duration
Attributes
seconds[R]
Public Class Methods
hours(hours)
click to toggle source
# File lib/biz/duration.rb, line 22 def hours(hours) new(hours * Time.hour_seconds) end
Also aliased as: hour
minutes(minutes)
click to toggle source
# File lib/biz/duration.rb, line 16 def minutes(minutes) new(minutes * Time.minute_seconds) end
Also aliased as: minute
new(seconds)
click to toggle source
# File lib/biz/duration.rb, line 30 def initialize(seconds) @seconds = Integer(seconds) end
seconds(seconds)
click to toggle source
# File lib/biz/duration.rb, line 10 def seconds(seconds) new(seconds) end
Also aliased as: second
Public Instance Methods
+(other)
click to toggle source
# File lib/biz/duration.rb, line 46 def +(other) self.class.new(seconds + other.seconds) end
-(other)
click to toggle source
# File lib/biz/duration.rb, line 50 def -(other) self.class.new(seconds - other.seconds) end
abs()
click to toggle source
# File lib/biz/duration.rb, line 58 def abs self.class.new(seconds.abs) end
in_hours()
click to toggle source
# File lib/biz/duration.rb, line 42 def in_hours seconds / Time.hour_seconds end
in_minutes()
click to toggle source
# File lib/biz/duration.rb, line 38 def in_minutes seconds / Time.minute_seconds end
in_seconds()
click to toggle source
# File lib/biz/duration.rb, line 34 def in_seconds seconds end
positive?()
click to toggle source
# File lib/biz/duration.rb, line 54 def positive? seconds.positive? end
Private Instance Methods
<=>(other)
click to toggle source
# File lib/biz/duration.rb, line 68 def <=>(other) return unless other.is_a?(self.class) seconds <=> other.seconds end