Class: DeviceCommand
Instance Attribute Summary
Attributes inherited from Command
#args
Instance Method Summary
collapse
Methods inherited from Command
all, #execute, inherited, #initialize, load, #name
Constructor Details
This class inherits a constructor from Command
Instance Method Details
#description ⇒ Object
197
198
199
|
# File 'lib/replicant/command.rb', line 197
def description
"set a default device to work with"
end
|
#run ⇒ Object
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/replicant/command.rb', line 209
def run
default_device = if index?
devices[args.to_i]
else
devices.detect { |d| d.id == args }
end
if default_device
output "Setting default device to #{default_device.inspect}"
@repl.default_device = default_device
else
output "No such device"
end
end
|
#usage ⇒ Object
201
202
203
|
# File 'lib/replicant/command.rb', line 201
def usage
"#{name} [<index>|<device_id>]"
end
|
#valid_args? ⇒ Boolean
205
206
207
|
# File 'lib/replicant/command.rb', line 205
def valid_args?
args.present? && /\S+/ =~ args
end
|