Class: RRule::Weekday
- Inherits:
-
Object
- Object
- RRule::Weekday
- Defined in:
- lib/rrule/weekday.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#ordinal ⇒ Object
readonly
Returns the value of attribute ordinal.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(index, ordinal = nil) ⇒ Weekday
constructor
A new instance of Weekday.
Constructor Details
#initialize(index, ordinal = nil) ⇒ Weekday
Returns a new instance of Weekday.
5 6 7 8 |
# File 'lib/rrule/weekday.rb', line 5 def initialize(index, ordinal = nil) @index = index @ordinal = ordinal end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
3 4 5 |
# File 'lib/rrule/weekday.rb', line 3 def index @index end |
#ordinal ⇒ Object (readonly)
Returns the value of attribute ordinal.
3 4 5 |
# File 'lib/rrule/weekday.rb', line 3 def ordinal @ordinal end |
Class Method Details
.parse(weekday) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rrule/weekday.rb', line 10 def self.parse(weekday) match = /([+-]?\d)?([A-Z]{2})/.match(weekday) index = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'].index(match[2]) ordinal = match[1] ? match[1].to_i : nil new(index, ordinal) end |