Class: DoubleEntry::YearRange
Instance Attribute Summary collapse
Attributes inherited from TimeRange
#day, #finish, #hour, #month, #range_type, #start, #week
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from TimeRange
#human_readable_name, #include?, #key, make, range_from_time_for_period
Constructor Details
#initialize(options) ⇒ YearRange
Returns a new instance of YearRange.
7
8
9
10
11
12
13
|
# File 'lib/double_entry/year_range.rb', line 7
def initialize(options)
super options
year_start = Time.local(@year, 1, 1)
@start = year_start
@finish = year_start.end_of_year
end
|
Instance Attribute Details
#year ⇒ Object
Returns the value of attribute year.
5
6
7
|
# File 'lib/double_entry/year_range.rb', line 5
def year
@year
end
|
Class Method Details
.current ⇒ Object
15
16
17
|
# File 'lib/double_entry/year_range.rb', line 15
def self.current
YearRange.new(:year => Time.now.year)
end
|
.from_time(time) ⇒ Object
19
20
21
|
# File 'lib/double_entry/year_range.rb', line 19
def self.from_time(time)
YearRange.new(:year => time.year)
end
|
Instance Method Details
#==(other) ⇒ Object
23
24
25
|
# File 'lib/double_entry/year_range.rb', line 23
def ==(other)
self.year == other.year
end
|
#next ⇒ Object
31
32
33
|
# File 'lib/double_entry/year_range.rb', line 31
def next
YearRange.new(:year => year + 1)
end
|
#previous ⇒ Object
27
28
29
|
# File 'lib/double_entry/year_range.rb', line 27
def previous
YearRange.new(:year => year - 1)
end
|
#to_s ⇒ Object
35
36
37
|
# File 'lib/double_entry/year_range.rb', line 35
def to_s
year.to_s
end
|