Class: Ballista::Frequencies::Monthly

Inherits:
Base
  • Object
show all
Defined in:
lib/ballista/frequencies/monthly.rb

Overview

Monthly actions

Instance Method Summary collapse

Methods inherited from Base

#entry

Constructor Details

#initialize(*_) ⇒ Monthly

Returns a new instance of Monthly.



6
7
8
9
# File 'lib/ballista/frequencies/monthly.rb', line 6

def initialize(*_)
  super
  @when = [@when] unless @when.is_a? Array
end

Instance Method Details

#get_dates(log, pointer, counter) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/ballista/frequencies/monthly.rb', line 18

def get_dates(log, pointer, counter)
  date = pointer >> counter
  return log if date > @stop
  return get_dates(log, pointer, counter + 1) if date < @start
  log << entry(date)
  get_dates(log, pointer, counter + 1)
end

#logObject



11
12
13
14
15
16
# File 'lib/ballista/frequencies/monthly.rb', line 11

def log
  @when.flat_map do |date|
    pointer = Date.new(Date.today.year, 1, date)
    get_dates([], pointer, 0)
  end
end