Class: Roby::Interface::V2::Async::UIConnector::SetArgumentCommand

Inherits:
ActionConnector show all
Defined in:
lib/roby/interface/v2/async/ui_connector.rb

Instance Attribute Summary collapse

Attributes inherited from ActionConnector

#action, #connector, #options

Instance Method Summary collapse

Methods inherited from ActionConnector

#interface

Constructor Details

#initialize(connector, action, argument_name, getter: nil) ⇒ SetArgumentCommand

Returns a new instance of SetArgumentCommand.



75
76
77
78
# File 'lib/roby/interface/v2/async/ui_connector.rb', line 75

def initialize(connector, action, argument_name, getter: nil)
    super(connector, action, getter: nil)
    @argument_name = argument_name.to_sym
end

Instance Attribute Details

#argument_nameObject (readonly)

Returns the value of attribute argument_name.



73
74
75
# File 'lib/roby/interface/v2/async/ui_connector.rb', line 73

def argument_name
  @argument_name
end

Instance Method Details

#run(arg) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/roby/interface/v2/async/ui_connector.rb', line 80

def run(arg)
    if getter = options[:getter]
        arg = getter.call(arg)
        unless arg
            Interface.warn "not setting argument #{action}.#{argument_name}: getter returned nil"
            return
        end
    end
    action.arguments[argument_name] = arg
    if options[:auto_apply]
        StartAction.new(connector, action, restart: true).run
    end
end