Class: Tempora::Year

Inherits:
TimePeriod show all
Extended by:
Initialization
Includes:
HasMonths, HasWeeks
Defined in:
lib/year.rb

Instance Attribute Summary collapse

Attributes inherited from TimePeriod

#end_date, #start_date

Instance Method Summary collapse

Methods included from Initialization

from, now

Methods included from HasMonths

#each_month, #months

Methods included from HasWeeks

#each_week, #weeks

Methods inherited from TimePeriod

#<=>, #contains?, #duration, #hash, #intersection, #overlaps?, #range, #shift

Methods included from HasTime

#end_time, #start_time

Methods included from HasDays

#days, #each_day

Constructor Details

#initialize(year) ⇒ Year

Returns a new instance of Year.



14
15
16
17
18
19
# File 'lib/year.rb', line 14

def initialize(year)
  @year = Integer(year)

  @start_date = Date.new(@year, 1, 1)
  @end_date   = Date.new(@year, 12, 31)
end

Instance Attribute Details

#yearObject (readonly)

Returns the value of attribute year.



12
13
14
# File 'lib/year.rb', line 12

def year
  @year
end

Instance Method Details

#idObject



21
22
23
# File 'lib/year.rb', line 21

def id
  year
end

#nextObject Also known as: succ



29
30
31
# File 'lib/year.rb', line 29

def next
  self.class.new(year + 1)
end

#prevObject Also known as: pred



33
34
35
# File 'lib/year.rb', line 33

def prev
  self.class.new(year - 1)
end

#to_sObject



25
26
27
# File 'lib/year.rb', line 25

def to_s
  year.to_s
end