Class: Eventual::Period

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

Overview

:nodoc:

Direct Known Subclasses

DatePeriod, MonthPeriod

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)


155
156
157
158
# File 'lib/eventual/syntax_nodes.rb', line 155

def include? date
  return false unless date_within_weekdays? date
  range.cover? date
end

#map(&block) ⇒ Object



160
161
162
163
164
165
# File 'lib/eventual/syntax_nodes.rb', line 160

def map &block
  range.map do |date|
    next unless date_within_weekdays? date
    (times ? make(date.year, date.month, date.day) : [date]).map(&block)
  end.compact
end

#rangeObject



151
152
153
# File 'lib/eventual/syntax_nodes.rb', line 151

def range
  (first..last)
end