Class: RRule::Weekday

Inherits:
Object
  • Object
show all
Defined in:
lib/rrule/weekday.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, ordinal = nil) ⇒ Weekday

Returns a new instance of Weekday.



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

def initialize(index, ordinal = nil)
  @index = index
  @ordinal = ordinal
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



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

def index
  @index
end

#ordinalObject (readonly)

Returns the value of attribute ordinal.



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

def ordinal
  @ordinal
end

Class Method Details

.parse(weekday) ⇒ Object



12
13
14
15
16
17
# File 'lib/rrule/weekday.rb', line 12

def self.parse(weekday)
  match = /([+-]?\d+)?([A-Z]{2})/.match(weekday)
  index = RRule::WEEKDAYS.index(match[2])
  ordinal = match[1]&.to_i
  new(index, ordinal)
end