Class: DaySet

Inherits:
Array
  • Object
show all
Defined in:
lib/day_set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ DaySet

Returns a new instance of DaySet.



13
14
15
16
17
18
19
# File 'lib/day_set.rb', line 13

def initialize(args)
  @date         = args[:date]
  @group_number = args[:group_number]
  @move_residue = args[:move_residue]
  @sets         = gen_range!.each_slice(@group_number).to_a
  move_residue! if @move_residue
end

Instance Attribute Details

#setsObject (readonly)

Returns the value of attribute sets.



4
5
6
# File 'lib/day_set.rb', line 4

def sets
  @sets
end

Class Method Details

.gen_for_year(year, options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/day_set.rb', line 21

def self.gen_for_year(year, options)
  sets = []

  (1..12).each do |month|
    date = Date.new year, month
    self.new(options.merge(:date => date)).sets.each do |s|
      sets << s
    end
  end

  sets
end

Instance Method Details

#last_day_of_the_monthObject



6
7
8
9
10
11
# File 'lib/day_set.rb', line 6

def last_day_of_the_month
  d = Date.new @date.year, @date.month
  d += 42
  last_d = Date.new(d.year, d.month) - 1
  last_d.day
end