class YearMonth

Attributes

month[R]
year[R]

Public Class Methods

new(a, b = nil) click to toggle source
# File lib/gitstats/yearmonth.rb, line 7
def initialize(a, b = nil)
  if a.is_a? Time
    @year = a.year
    @month = a.month
  elsif b.nil?
    @year = (a / 100).to_i
    @month = a % 100
  else
    @year = a.to_i
    @month = b.to_i
  end
end

Public Instance Methods

<=>(b) click to toggle source
# File lib/gitstats/yearmonth.rb, line 20
def <=>(b)
  to_i <=> b.to_i
end
eql?(b) click to toggle source
# File lib/gitstats/yearmonth.rb, line 32
def eql?(b)
  to_i == b.to_i
end
hash() click to toggle source
# File lib/gitstats/yearmonth.rb, line 36
def hash
  to_i
end
to_i() click to toggle source
# File lib/gitstats/yearmonth.rb, line 24
def to_i
  @year * 12 + @month - 1
end
to_s() click to toggle source
# File lib/gitstats/yearmonth.rb, line 28
def to_s
  '%04d-%02d' % [@year, @month]
end