Class: Eventual::Node
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Eventual::Node
- Defined in:
- lib/eventual/syntax_nodes.rb
Instance Attribute Summary collapse
-
#month ⇒ Object
Returns the value of attribute month.
-
#times ⇒ Object
Returns the value of attribute times.
-
#weekdays ⇒ Object
Returns the value of attribute weekdays.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
-
#date_within_weekdays?(date) ⇒ Boolean
Returns true if the weekday (as number) correspons to any allowed weekday.
-
#first ⇒ Object
Returns last Date or DateTime of the encompassed period.
-
#include?(date) ⇒ Boolean
Returns true if the Date or DateTime passed is included in the parsed Dates or DateTimes.
-
#last ⇒ Object
Returns last Date or DateTime of the encompassed period.
-
#map(&block) ⇒ Object
Invokes block once for each Date or DateTime.
-
#to_a ⇒ Object
Returns an array with all the encompassed Dates or DateTimes.
Instance Attribute Details
#month ⇒ Object
Returns the value of attribute month.
55 56 57 |
# File 'lib/eventual/syntax_nodes.rb', line 55 def month @month end |
#times ⇒ Object
Returns the value of attribute times.
57 58 59 |
# File 'lib/eventual/syntax_nodes.rb', line 57 def times @times end |
#weekdays ⇒ Object
Returns the value of attribute weekdays.
56 57 58 |
# File 'lib/eventual/syntax_nodes.rb', line 56 def weekdays @weekdays end |
#year ⇒ Object
Returns the value of attribute year.
54 55 56 |
# File 'lib/eventual/syntax_nodes.rb', line 54 def year @year end |
Instance Method Details
#date_within_weekdays?(date) ⇒ Boolean
Returns true if the weekday (as number) correspons to any allowed weekday
71 72 73 74 |
# File 'lib/eventual/syntax_nodes.rb', line 71 def date_within_weekdays? date return true unless weekdays weekdays.include? date.wday end |
#first ⇒ Object
Returns last Date or DateTime of the encompassed period
63 64 65 |
# File 'lib/eventual/syntax_nodes.rb', line 63 def first; to_a.first end |
#include?(date) ⇒ Boolean
Returns true if the Date or DateTime passed is included in the parsed Dates or DateTimes
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/eventual/syntax_nodes.rb', line 82 def include? date result = false walk { |elements| break result = true if elements.include? date } return result if !result || date.class == Date || times.nil? times.include? date end |
#last ⇒ Object
Returns last Date or DateTime of the encompassed period
60 |
# File 'lib/eventual/syntax_nodes.rb', line 60 def last; to_a.last end |
#map(&block) ⇒ Object
Invokes block once for each Date or DateTime. Creates a new array containing the values returned by the block.
77 78 79 |
# File 'lib/eventual/syntax_nodes.rb', line 77 def map &block walk { |elements| elements.map &block }.compact end |
#to_a ⇒ Object
Returns an array with all the encompassed Dates or DateTimes
68 |
# File 'lib/eventual/syntax_nodes.rb', line 68 def to_a; map{ |e| e } end |