Module: Periods::Modules::Year::InstanceMethods
- Defined in:
- lib/periods/modules/year.rb
Instance Method Summary collapse
- #days ⇒ Object
- #initialize(date) ⇒ Object
- #months ⇒ Object
-
#next ⇒ Object
01.06.2015 => 01.06.2016.
-
#previous ⇒ Object
01.06.2015 => 01.06.2014.
- #year ⇒ Object
Instance Method Details
#days ⇒ Object
46 47 48 |
# File 'lib/periods/modules/year.rb', line 46 def days (self.next.start_date - start_date).to_i end |
#initialize(date) ⇒ Object
27 28 29 30 |
# File 'lib/periods/modules/year.rb', line 27 def initialize(date) date = Date.parse(date.to_s) super(beginning_of_month(date), end_of_month(beginning_of_month(date).next_year.prev_day)) end |
#months ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/periods/modules/year.rb', line 54 def months months = [Periods::Month.for(start_date)] 1.upto(11) do |idx| months << Periods::Month.for(start_date.next_month(idx)) end months end |
#next ⇒ Object
01.06.2015 => 01.06.2016
35 36 37 |
# File 'lib/periods/modules/year.rb', line 35 def next self.class.for(start_date.next_year) end |
#previous ⇒ Object
01.06.2015 => 01.06.2014
42 43 44 |
# File 'lib/periods/modules/year.rb', line 42 def previous self.class.for(start_date.prev_year) end |
#year ⇒ Object
50 51 52 |
# File 'lib/periods/modules/year.rb', line 50 def year start_date.year end |