Class: Timezone::Parser::Rule::On
- Inherits:
-
Object
- Object
- Timezone::Parser::Rule::On
- Defined in:
- lib/timezone/parser/rule/on.rb
Constant Summary collapse
- @@rules =
[]
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
Class Method Summary collapse
-
.parse(day, month, year) ⇒ Object
Given a Rule ‘on` field, parse the appropriate day and month.
Instance Method Summary collapse
-
#initialize(name, expression, block) ⇒ On
constructor
A new instance of On.
Constructor Details
#initialize(name, expression, block) ⇒ On
Returns a new instance of On.
23 24 25 26 27 28 |
# File 'lib/timezone/parser/rule/on.rb', line 23 def initialize(name, expression, block) @name = name @expression = expression @block = block @@rules << self end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
21 22 23 |
# File 'lib/timezone/parser/rule/on.rb', line 21 def block @block end |
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
21 22 23 |
# File 'lib/timezone/parser/rule/on.rb', line 21 def expression @expression end |
Class Method Details
.parse(day, month, year) ⇒ Object
Given a Rule ‘on` field, parse the appropriate day and month.
11 12 13 14 15 16 17 18 19 |
# File 'lib/timezone/parser/rule/on.rb', line 11 def self.parse(day, month, year) @@rules.each do |rule| if match = day.match(rule.expression) return rule.block.call(match, day, month, year) end end [month, day] end |