Class: Roby::Coordination::Models::Capture
- Defined in:
- lib/roby/coordination/models/capture.rb
Overview
Object that is used to represent the context of an event context
Defined Under Namespace
Classes: CaptureEvaluationContext, Unbound
Instance Attribute Summary collapse
-
#name ⇒ String
The capture name.
Instance Method Summary collapse
-
#evaluate(variables) ⇒ Object
Evaluate the capture.
- #evaluate_delayed_argument(task) ⇒ Object
-
#filter(state_machine, event) ⇒ Object
Filter the context through the filter object passed to #initialize.
-
#initialize(filter = lambda(&:context)) ⇒ Capture
constructor
Create a new capture object.
- #to_s ⇒ Object
Constructor Details
#initialize(filter = lambda(&:context)) ⇒ Capture
Create a new capture object
20 21 22 |
# File 'lib/roby/coordination/models/capture.rb', line 20 def initialize(filter = lambda(&:context)) @filter = filter end |
Instance Attribute Details
#name ⇒ String
The capture name
Only used for debugging purposes
13 14 15 |
# File 'lib/roby/coordination/models/capture.rb', line 13 def name @name end |
Instance Method Details
#evaluate(variables) ⇒ Object
Evaluate the capture
76 77 78 79 80 81 82 |
# File 'lib/roby/coordination/models/capture.rb', line 76 def evaluate(variables) if variables.has_key?(self) variables[self] else raise Unbound.new(self), "#{self} is not bound yet" end end |
#evaluate_delayed_argument(task) ⇒ Object
66 67 68 |
# File 'lib/roby/coordination/models/capture.rb', line 66 def evaluate_delayed_argument(task) throw :no_value end |
#filter(state_machine, event) ⇒ Object
Filter the context through the filter object passed to #initialize
26 27 28 29 |
# File 'lib/roby/coordination/models/capture.rb', line 26 def filter(state_machine, event) CaptureEvaluationContext.new(state_machine) .instance_exec(event, &@filter) end |
#to_s ⇒ Object
84 85 86 |
# File 'lib/roby/coordination/models/capture.rb', line 84 def to_s "capture:#{name || '<unnamed>'}" end |