Class: Roby::Coordination::Models::TaskFromVariable
- Inherits:
-
TaskWithDependencies
- Object
- Task
- TaskWithDependencies
- Roby::Coordination::Models::TaskFromVariable
- Defined in:
- lib/roby/coordination/models/task_from_variable.rb
Overview
State whose instanciation object is provided through a state machine variable
Instance Attribute Summary collapse
-
#variable_name ⇒ Object
readonly
Returns the value of attribute variable_name.
Attributes inherited from TaskWithDependencies
Attributes inherited from Task
Instance Method Summary collapse
-
#initialize(variable_name, task_model) ⇒ TaskFromVariable
constructor
A new instance of TaskFromVariable.
- #instanciate(plan, variables = {}) ⇒ Object
- #to_s ⇒ Object
Methods inherited from TaskWithDependencies
#depends_on, #find_child_model, #initialize_copy, #map_tasks
Methods inherited from Task
#can_resolve_child_models?, #find_child, #find_child_model, #find_event, #find_through_method_missing, #has_child?, #has_event?, #has_through_method_missing?, #map_tasks, #new, #rebind, #setup_instanciated_task, #to_coordination_task
Constructor Details
#initialize(variable_name, task_model) ⇒ TaskFromVariable
Returns a new instance of TaskFromVariable.
11 12 13 14 |
# File 'lib/roby/coordination/models/task_from_variable.rb', line 11 def initialize(variable_name, task_model) @variable_name = variable_name super(task_model) end |
Instance Attribute Details
#variable_name ⇒ Object (readonly)
Returns the value of attribute variable_name.
9 10 11 |
# File 'lib/roby/coordination/models/task_from_variable.rb', line 9 def variable_name @variable_name end |
Instance Method Details
#instanciate(plan, variables = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/roby/coordination/models/task_from_variable.rb', line 16 def instanciate(plan, variables = {}) obj = variables[variable_name] unless obj.respond_to?(:as_plan) raise ArgumentError, "expected variable #{variable_name} to contain an object that can generate tasks, found #{obj}" end obj.as_plan end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/roby/coordination/models/task_from_variable.rb', line 25 def to_s "var(#{variable_name})[#{task_model}]" end |