Class: Roby::Actions::Action
- Includes:
- DRoby::V5::Actions::ActionDumper
- Defined in:
- lib/roby/actions/action.rb,
lib/roby/droby/enable.rb
Overview
The representation of an action, as a model and arguments
Instance Attribute Summary collapse
-
#arguments ⇒ Hash
readonly
The action arguments.
-
#model ⇒ Models::Action
The action model.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#as_plan(**arguments) ⇒ Roby::Task
Returns a plan pattern that would deploy this action in the plan.
- #has_missing_required_arg? ⇒ Boolean
-
#initialize(model, **arguments) ⇒ Action
constructor
A new instance of Action.
-
#instanciate(plan, **arguments) ⇒ Object
Deploys this action on the given plan.
- #name ⇒ Object
- #rebind(action_interface_model) ⇒ Object
-
#returned_type ⇒ Object
The task model returned by this action.
- #to_action ⇒ Object
- #to_coordination_task(task_model = Roby::Task) ⇒ Object
- #to_s ⇒ Object
-
#with_arguments(**arguments) ⇒ self
Update this object with new arguments and returns it.
Methods included from DRoby::V5::Actions::ActionDumper
#droby_dump, #droby_dump!, #proxy, #proxy!
Constructor Details
#initialize(model, **arguments) ⇒ Action
Returns a new instance of Action.
12 13 14 |
# File 'lib/roby/actions/action.rb', line 12 def initialize(model, **arguments) @model, @arguments = model, arguments end |
Instance Attribute Details
#arguments ⇒ Hash (readonly)
The action arguments
10 11 12 |
# File 'lib/roby/actions/action.rb', line 10 def arguments @arguments end |
#model ⇒ Models::Action
The action model
7 8 9 |
# File 'lib/roby/actions/action.rb', line 7 def model @model end |
Instance Method Details
#==(other) ⇒ Object
20 21 22 23 24 |
# File 'lib/roby/actions/action.rb', line 20 def ==(other) other.kind_of?(Action) && model == other.model && arguments == other.arguments end |
#as_plan(**arguments) ⇒ Roby::Task
Returns a plan pattern that would deploy this action in the plan
54 55 56 |
# File 'lib/roby/actions/action.rb', line 54 def as_plan(**arguments) model.plan_pattern(**self.arguments.merge(arguments)) end |
#has_missing_required_arg? ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/roby/actions/action.rb', line 35 def has_missing_required_arg? model.arguments.any? do |arg| arg_sym = arg.name.to_sym if arguments.has_key?(arg_sym) TaskArguments.delayed_argument?(arguments.fetch(arg_sym)) else arg.required? end end end |
#instanciate(plan, **arguments) ⇒ Object
Deploys this action on the given plan
63 64 65 |
# File 'lib/roby/actions/action.rb', line 63 def instanciate(plan, **arguments) model.instanciate(plan, self.arguments.merge(arguments)) end |
#name ⇒ Object
16 17 18 |
# File 'lib/roby/actions/action.rb', line 16 def name model.name end |
#rebind(action_interface_model) ⇒ Object
58 59 60 |
# File 'lib/roby/actions/action.rb', line 58 def rebind(action_interface_model) model.rebind(action_interface_model).new(**arguments) end |
#returned_type ⇒ Object
The task model returned by this action
47 48 49 |
# File 'lib/roby/actions/action.rb', line 47 def returned_type model.returned_type end |
#to_action ⇒ Object
75 76 77 |
# File 'lib/roby/actions/action.rb', line 75 def to_action self end |
#to_coordination_task(task_model = Roby::Task) ⇒ Object
71 72 73 |
# File 'lib/roby/actions/action.rb', line 71 def to_coordination_task(task_model = Roby::Task) Coordination::Models::TaskFromAction.new(self) end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/roby/actions/action.rb', line 67 def to_s "#{model}(#{arguments.map { |k,v| "#{k} => #{v}" }.sort.join(", ")})" end |
#with_arguments(**arguments) ⇒ self
Update this object with new arguments and returns it
30 31 32 33 |
# File 'lib/roby/actions/action.rb', line 30 def with_arguments(**arguments) @arguments.merge!(arguments) self end |