class NumRu::Units::XDate

Attributes

day[R]
month[R]
year[R]

Public Class Methods

new(year, month, day) click to toggle source
# File lib/numru/units.rb, line 2251
def initialize(year, month, day)
    @year, @month, @day = year.to_i, month.to_i, day.to_i
end

Public Instance Methods

+(other) click to toggle source
# File lib/numru/units.rb, line 2284
def +(other)
    t = to_date + other
    self.class.new(t.year, t.month, t.mday)
end
-(other) click to toggle source
# File lib/numru/units.rb, line 2271
def -(other)
    case other
    when XDate
        (to_date - other.to_date)
    when Time
        to_time - other
    when Date
        (to_date - other.to_date)
    else
        to_date - other
    end
end
inspect()
Alias for: to_s
to_date() click to toggle source
# File lib/numru/units.rb, line 2267
def to_date
    Date.new(@year, @month, @day)
end
to_s() click to toggle source
# File lib/numru/units.rb, line 2257
def to_s
    format('%04d-%02d-%02d', @year, @month, @day)
end
Also aliased as: inspect
to_time() click to toggle source
# File lib/numru/units.rb, line 2263
def to_time
    Time.gm(@year, @month, @day)
end