Class: RRule::BySetPosition
- Inherits:
-
Object
- Object
- RRule::BySetPosition
- Defined in:
- lib/rrule/generators/by_set_position.rb
Instance Attribute Summary collapse
-
#by_set_positions ⇒ Object
readonly
Returns the value of attribute by_set_positions.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #combine_dates_and_times(dayset, timeset) ⇒ Object
-
#initialize(by_set_positions, context) ⇒ BySetPosition
constructor
A new instance of BySetPosition.
- #valid_dates(dayset) ⇒ Object
Constructor Details
#initialize(by_set_positions, context) ⇒ BySetPosition
Returns a new instance of BySetPosition.
5 6 7 8 |
# File 'lib/rrule/generators/by_set_position.rb', line 5 def initialize(by_set_positions, context) @by_set_positions = by_set_positions @context = context end |
Instance Attribute Details
#by_set_positions ⇒ Object (readonly)
Returns the value of attribute by_set_positions.
3 4 5 |
# File 'lib/rrule/generators/by_set_position.rb', line 3 def by_set_positions @by_set_positions end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/rrule/generators/by_set_position.rb', line 3 def context @context end |
Instance Method Details
#combine_dates_and_times(dayset, timeset) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rrule/generators/by_set_position.rb', line 10 def combine_dates_and_times(dayset, timeset) valid_dates(dayset).flat_map do |date| timeset.map do |time| Time.use_zone(context.tz) do Time.zone.local( date.year, date.month, date.day, time[:hour], time[:minute], time[:second] ) end end end end |
#valid_dates(dayset) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/rrule/generators/by_set_position.rb', line 27 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 |