Parent

Included Modules

ExpressionBuilder

Convenience class for building temporal expressions in a more human-friendly way. Used in conjunction with shortcuts defined in the sugar.rb file, this allows one to create expressions like the following:

b = ExpressionBuilder.new
expr = b.define do
  occurs daily_8_30am_to_9_45am
  on tuesday
  possibly wednesday
end

This equivalent to:

expr = REDay.new(8,30,9,45) & DIWeek.new(Tuesday) | DIWeek.new(Wednesday)

ExpressionBuilder creates expressions by evaluating a block passed to the :define method. From inside the block, methods :occurs, :on, :every, :possibly, and :maybe can be called with a temporal expression which will be added to a composite expression as follows:

Attributes

ctx[RW]

Public Class Methods

new() click to toggle source
# File lib/runt/expressionbuilder.rb, line 36
def initialize
  @ctx = nil
end

Public Instance Methods

add(expr, op) click to toggle source
# File lib/runt/expressionbuilder.rb, line 48
def add(expr, op)
  @ctx ||= expr
  @ctx = @ctx.send(op, expr) unless @ctx == expr
  @ctx # explicit return, previous line may not execute
end
define(&block) click to toggle source
# File lib/runt/expressionbuilder.rb, line 40
def define(&block)
  instance_eval(&block)
end
every(expr) click to toggle source
Alias for: on
except(expr) click to toggle source
# File lib/runt/expressionbuilder.rb, line 54
def except(expr)
  add(expr, :-)
end
maybe(expr) click to toggle source
Alias for: possibly
occurs(expr) click to toggle source
Alias for: on
on(expr) click to toggle source
# File lib/runt/expressionbuilder.rb, line 44
def on(expr)
  add(expr, :&)
end
Also aliased as: every, occurs
possibly(expr) click to toggle source
# File lib/runt/expressionbuilder.rb, line 58
def possibly(expr)
  add(expr, :|)
end
Also aliased as: maybe

[Validate]

Generated with the Darkfish Rdoc Generator 2.