Class: Tempora::Year
Instance Attribute Summary collapse
Attributes inherited from TimePeriod
#end_date, #start_date
Instance Method Summary
collapse
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
#year ⇒ Object
Returns the value of attribute year.
12
13
14
|
# File 'lib/year.rb', line 12
def year
@year
end
|
Instance Method Details
#id ⇒ Object
21
22
23
|
# File 'lib/year.rb', line 21
def id
year
end
|
#next ⇒ Object
Also known as:
succ
29
30
31
|
# File 'lib/year.rb', line 29
def next
self.class.new(year + 1)
end
|
#prev ⇒ Object
Also known as:
pred
33
34
35
|
# File 'lib/year.rb', line 33
def prev
self.class.new(year - 1)
end
|
#to_s ⇒ Object
25
26
27
|
# File 'lib/year.rb', line 25
def to_s
year.to_s
end
|