Module: Duration::Common

Includes:
Comparable
Included in:
Days, Hours, Microseconds, Milliseconds, Minutes, Months, Nanoseconds, Seconds, Weeks
Defined in:
lib/Duration/Common.rb

Instance Method Summary collapse

Instance Method Details

#+(other) ⇒ Object



8
9
10
# File 'lib/Duration/Common.rb', line 8

def +(other)
  combine(:+, other)
end

#-(other) ⇒ Object



12
13
14
# File 'lib/Duration/Common.rb', line 12

def -(other)
  combine(:-, other)
end

#<=>(other) ⇒ Object



16
17
18
19
# File 'lib/Duration/Common.rb', line 16

def <=>(other)
  return nil unless other.is_a?(Duration::Common)
  quantity <=> other.send(:"to_#{unit}").quantity
end