Class: Eventual::Day

Inherits:
Node
  • Object
show all
Defined in:
lib/eventual/syntax_nodes.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Node

#month, #times, #weekdays, #year

Instance Method Summary collapse

Methods inherited from Node

#date_within_weekdays?, #first, #last, #to_a

Instance Method Details

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/eventual/syntax_nodes.rb', line 145

def include? date
  map { |element| [*element].map{ |e| e.strftime("%Y-%m-%d") } }.flatten.include? date.strftime("%Y-%m-%d")
end

#map(&block) ⇒ Object

Raises:



138
139
140
141
142
143
# File 'lib/eventual/syntax_nodes.rb', line 138

def map &block
  dates = make(year, month, text_value.to_i)
  dates = [dates] unless Array === dates
  raise WdayMatchError.new(dates.first) unless date_within_weekdays? dates.first
  dates.map(&block).compact
end

#valueObject



134
135
136
# File 'lib/eventual/syntax_nodes.rb', line 134

def value
  Date.civil year, month, text_value.to_i
end