Class: ISO8601Basic::Date
- Inherits:
-
Date
- Object
- Date
- ISO8601Basic::Date
- Defined in:
- lib/iso8601_basic/date.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.new(*args) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/iso8601_basic/date.rb', line 3 def self.new(*args) case value = args[0] when Numeric then super when String dt = ::Date.iso8601 value super dt.year, dt.month, dt.day else super end end |
Instance Method Details
#+(other) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/iso8601_basic/date.rb', line 12 def +(other) case other when ISO8601Basic::Time ISO8601Basic::DateTime.new year, month, day, other.hour, other.minute, other.second, other.zone when ISO8601Basic::Duration { years: [:>>, 12], months: [:>>, 1], weeks: [:+, 7], days: [:+, 1] }.reduce self do |date, (key, (action, factor))| date.send action, other.to_h[key] * factor end else super end end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/iso8601_basic/date.rb', line 24 def inspect "#<ISO8601Basic::Date: #{iso8601}>" end |