Module: Periods::Modules::Year::InstanceMethods

Defined in:
lib/periods/modules/year.rb

Instance Method Summary collapse

Instance Method Details

#daysObject



30
31
32
# File 'lib/periods/modules/year.rb', line 30

def days
  (self.next.start_date - start_date).to_i
end

#halfyearsObject



50
51
52
# File 'lib/periods/modules/year.rb', line 50

def halfyears
  [Periods::Halfyear.for(start_date), Periods::Halfyear.for(start_date.next_month(6))]
end

#monthsObject



34
35
36
37
38
39
40
# File 'lib/periods/modules/year.rb', line 34

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

#nextObject

01.06.2015 => 01.06.2016



19
20
21
# File 'lib/periods/modules/year.rb', line 19

def next
  self.class.for(start_date.next_year)
end

#previousObject

01.06.2015 => 01.06.2014



26
27
28
# File 'lib/periods/modules/year.rb', line 26

def previous
  self.class.for(start_date.prev_year)
end

#quartersObject



42
43
44
45
46
47
48
# File 'lib/periods/modules/year.rb', line 42

def quarters
  quarters = [Periods::Quarter.for(start_date)]
  1.upto(3) do |idx|
    quarters << Periods::Quarter.for(start_date.next_month(idx*3))
  end
  quarters
end