Class: TExp::SingleTermBase

Inherits:
Base
  • Object
show all
Defined in:
lib/texp/base.rb

Overview

Base class for temporal expressions with a single sub-expressions (i.e. term).

Direct Known Subclasses

Not, Window

Instance Method Summary collapse

Methods inherited from Base

#*, #+, #-, #-@, #first_day_of_window, #last_day_of_window, parse_callback, register_parse_callback, #to_s, #window

Constructor Details

#initialize(term) ⇒ SingleTermBase

Create a single term temporal expression.



220
221
222
# File 'lib/texp/base.rb', line 220

def initialize(term)
  @term = term
end

Instance Method Details

#each {|@term| ... } ⇒ Object

Iterate over all temporal expressions and subexpressions (in post order).

Yields:

  • (@term)


232
233
234
235
# File 'lib/texp/base.rb', line 232

def each()                  # :yield: temporal_expression
  yield @term
  yield self
end

#reanchor(date) ⇒ Object

Create a new temporal expression with a new anchor date.



225
226
227
228
# File 'lib/texp/base.rb', line 225

def reanchor(date)
  new_term = @term.reanchor(date)
  (@term == new_term) ? self : self.class.new(new_term)
end