Class: Roby::Coordination::Models::TaskFromVariable

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

Attributes inherited from TaskWithDependencies

#dependencies

Attributes inherited from Task

#model, #name

Instance Method Summary collapse

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.



8
9
10
11
# File 'lib/roby/coordination/models/task_from_variable.rb', line 8

def initialize(variable_name, task_model)
    @variable_name = variable_name
    super(task_model)
end

Instance Attribute Details

#variable_nameObject (readonly)

Returns the value of attribute variable_name.



7
8
9
# File 'lib/roby/coordination/models/task_from_variable.rb', line 7

def variable_name
  @variable_name
end

Instance Method Details

#instanciate(plan, variables = Hash.new) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/roby/coordination/models/task_from_variable.rb', line 13

def instanciate(plan, variables = Hash.new)
    obj = variables[variable_name]
    if !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_sObject



21
# File 'lib/roby/coordination/models/task_from_variable.rb', line 21

def to_s; "var(#{variable_name})[#{task_model}]" end