class WorkingHours::Duration
Constants
- SUPPORTED_KINDS
Attributes
kind[RW]
value[RW]
Public Class Methods
new(value, kind)
click to toggle source
# File lib/working_hours/duration.rb, line 11 def initialize(value, kind) raise ArgumentError.new("Invalid working time unit: #{kind}") unless SUPPORTED_KINDS.include?(kind) @value = value @kind = kind end
Public Instance Methods
-@()
click to toggle source
Value object methods
# File lib/working_hours/duration.rb, line 29 def -@ Duration.new(-value, kind) end
==(other)
click to toggle source
# File lib/working_hours/duration.rb, line 33 def ==(other) self.class == other.class and kind == other.kind and value == other.value end
Also aliased as: eql?
hash()
click to toggle source
# File lib/working_hours/duration.rb, line 38 def hash [self.class, kind, value].hash end
since(time = ::Time.current)
click to toggle source
# File lib/working_hours/duration.rb, line 23 def since(time = ::Time.current) ::WorkingHours.send("add_#{@kind}", time, @value) end
Also aliased as: from_now
until(time = ::Time.current)
click to toggle source
Computation
methods
# File lib/working_hours/duration.rb, line 18 def until(time = ::Time.current) ::WorkingHours.send("add_#{@kind}", time, -@value) end
Also aliased as: ago