Class: DoubleEntry::Reporting::YearRange Private

Inherits:
TimeRange
  • Object
show all
Defined in:
lib/double_entry/reporting/year_range.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of YearRange.



7
8
9
10
11
12
13
# File 'lib/double_entry/reporting/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

#yearObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
# File 'lib/double_entry/reporting/year_range.rb', line 5

def year
  @year
end

Class Method Details

.currentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
# File 'lib/double_entry/reporting/year_range.rb', line 15

def self.current
  new(:year => Time.now.year)
end

.from_time(time) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/double_entry/reporting/year_range.rb', line 19

def self.from_time(time)
  new(:year => time.year)
end

Instance Method Details

#==(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/double_entry/reporting/year_range.rb', line 23

def ==(other)
  year == other.year
end

#nextObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/double_entry/reporting/year_range.rb', line 31

def next
  YearRange.new(:year => year + 1)
end

#previousObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/double_entry/reporting/year_range.rb', line 27

def previous
  YearRange.new(:year => year - 1)
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
# File 'lib/double_entry/reporting/year_range.rb', line 35

def to_s
  year.to_s
end