Class: Eventual::TimeList

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/eventual/syntax_nodes.rb

Overview

:nodoc:

Direct Known Subclasses

TimeRangeList

Instance Method Summary collapse

Instance Method Details

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


204
205
206
# File 'lib/eventual/syntax_nodes.rb', line 204

def include? date
  map { |time| time.to_i }.include? date.strftime("%H%M").to_i
end

#make(year, month, day) ⇒ Object



200
201
202
# File 'lib/eventual/syntax_nodes.rb', line 200

def make year, month, day
  map { |time| DateTime.civil year, month, day, time.hour, time.minute }.sort
end

#mapObject



189
190
191
192
193
194
195
196
197
198
# File 'lib/eventual/syntax_nodes.rb', line 189

def map
  walk_times = lambda do |elements|
    break unless elements
    elements.map do |element|
      next walk_times.call(element.elements) unless Time === element
      block_given? ? yield(element) : element
    end
  end
  walk_times.call(elements).flatten.compact
end