Module: TExp

Extended by:
Builder, DSL
Defined in:
lib/texp/dsl.rb,
lib/texp/ext.rb,
lib/texp/base.rb,
lib/texp/week.rb,
lib/texp/year.rb,
lib/texp/logic.rb,
lib/texp/month.rb,
lib/texp/parse.rb,
lib/texp/errors.rb,
lib/texp/window.rb,
lib/texp/builder.rb,
lib/texp/version.rb,
lib/texp/every_day.rb,
lib/texp/operators.rb,
lib/texp/day_of_week.rb,
lib/texp/day_interval.rb,
lib/texp/day_of_month.rb

Defined Under Namespace

Modules: Builder, DSL, Extensions Classes: And, Base, DateArgumentError, DayInterval, DayOfMonth, DayOfWeek, Error, EvalEnvironment, EveryDay, Month, MultiTermBase, Not, Or, ParseCallback, ParseError, SingleTermBase, Week, Window, Year

Constant Summary collapse

PARSE_CALLBACKS =

:nodoc:

{}
TOKEN_PATTERNS =

Lexical Definitions

[
  # Dates
  '\d\d\d\d-\d\d-\d\d',
  # Numbers
  '[+-]?\d+',
  # Extension Tokens
  '<(?:[a-zA-Z_][a-zA-Z0-9_]*::)?[a-zA-Z_][a-zA-Z0-9_]*>',
  # Everything else is a single character
  # (except commas and spaces which are ignored)
  '[^, ]',
].join('|')
TOKEN_RE =

:nodoc:

Regexp.new(TOKEN_PATTERNS)
MARK =

Mark the end of the list.

:mark
VERSION =
'0.0.7'

Class Method Summary collapse

Methods included from DSL

day, dow, evaluate_expression_in_environment, every, month, normalize_units, on, week, year

Methods included from Builder

day, dow, every, month, normalize_units, on, week, year

Class Method Details

.parse(string) ⇒ Object

Return the temporal expression encoded by string.



31
32
33
34
35
36
37
38
# File 'lib/texp/parse.rb', line 31

def parse(string)
  @stack = []
  string.scan(TOKEN_RE) do |tok|
    compile(tok)
  end
  fail ParseError, "Incomplete expression" if @stack.size > 1
  @stack.pop
end

.register_parse_callback(token, callback) ⇒ Object

Register a parsing callback. Individual Temporal Expression classes will register their own callbacks as needed. A handful of non-class based parser callbacks are registered below.



26
27
28
# File 'lib/texp/parse.rb', line 26

def register_parse_callback(token, callback)
  PARSE_CALLBACKS[token] = callback
end