Class: Roby::Coordination::Models::Capture

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#nameString

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

Raises:

  • Unbound if the capture’s backing event has not yet been emitted



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_sObject



84
85
86
# File 'lib/roby/coordination/models/capture.rb', line 84

def to_s
    "capture:#{name || '<unnamed>'}"
end