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, #include?, #last_day_of_window, parse_callback, register_parse_callback, #to_s, #window

Constructor Details

#initialize(term) ⇒ SingleTermBase

Create a single term temporal expression.



230
231
232
# File 'lib/texp/base.rb', line 230

def initialize(term)
  @term = term
end

Instance Method Details

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

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

Yields:

  • (@term)


242
243
244
245
# File 'lib/texp/base.rb', line 242

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

#reanchor(date) ⇒ Object

Create a new temporal expression with a new anchor date.



235
236
237
238
# File 'lib/texp/base.rb', line 235

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