class ISO8601Basic::Date

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# 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

Public Instance Methods

+(other) click to toggle source
Calls superclass method
# 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() click to toggle source
# File lib/iso8601_basic/date.rb, line 24
def inspect
  "#<ISO8601Basic::Date: #{iso8601}>"
end