class Koyomi::Year

Attributes

year[R]

Public Class Methods

new(year = nil) click to toggle source

initialize instance.

@param [Integer] year optional, default use the year of instance created.

Calls superclass method Koyomi::Period::new
# File lib/koyomi/year.rb, line 25
def initialize(year = nil)
  super()
  @year   = year||created_at.year
  @first  = Date.new(@year,  1,  1)
  @last   = Date.new(@year, 12, 31)
end
of(date = Date.today) click to toggle source

create instance from date

@param [Date] date @return [Koyomi::Year]

# File lib/koyomi/year.rb, line 13
def self.of(date = Date.today)
  self.new(date.year)
end

Public Instance Methods

leap?()
Alias for: uruu?
month(month) click to toggle source
# File lib/koyomi/year.rb, line 38
def month(month)
  Koyomi::Month.new(month, year)
end
uruu?() click to toggle source
# File lib/koyomi/year.rb, line 42
def uruu?
  begin
    Date.new(year, 2, 29)
  rescue ArgumentError => e
    false
  else
    true
  end
end
Also aliased as: leap?