Class: RRule::BySetPosition

Inherits:
Generator show all
Defined in:
lib/rrule/generators/by_set_position.rb

Instance Attribute Summary collapse

Attributes inherited from Generator

#context

Instance Method Summary collapse

Methods inherited from Generator

#process_timeset

Constructor Details

#initialize(by_set_positions, context) ⇒ BySetPosition

Returns a new instance of BySetPosition.



7
8
9
10
# File 'lib/rrule/generators/by_set_position.rb', line 7

def initialize(by_set_positions, context)
  @by_set_positions = by_set_positions
  super(context)
end

Instance Attribute Details

#by_set_positionsObject (readonly)

Returns the value of attribute by_set_positions.



5
6
7
# File 'lib/rrule/generators/by_set_position.rb', line 5

def by_set_positions
  @by_set_positions
end

Instance Method Details

#combine_dates_and_times(dayset, timeset) ⇒ Object



12
13
14
15
16
# File 'lib/rrule/generators/by_set_position.rb', line 12

def combine_dates_and_times(dayset, timeset)
  valid_dates(dayset).flat_map do |date|
    process_timeset(date, timeset)
  end
end

#valid_dates(dayset) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rrule/generators/by_set_position.rb', line 18

def valid_dates(dayset)
  dayset.compact!
  by_set_positions.map do |position|
    position -= 1 if position > 0
    dayset[position]
  end.compact.map { |i| context.first_day_of_year + i }
end