module Fuelcell::Action::Callable
Public Instance Methods
call(opts, args, shell)
click to toggle source
Executes this command.
@param opts [Hash] processed opts from the cli parser @param args [Array] processed args from the cli parser @param shell [Fuelcell::Shell] IO abstraction @return [Integer] the exit code
# File lib/fuelcell/action/callable.rb, line 31 def call(opts, args, shell) fail 'command is not be called, callable not assigned' unless callable? begin cast_exit_code callable.call(opts, args, shell) rescue StandardError => e shell.exception e end end
callable(value = nil)
click to toggle source
Both getter and setting for callable object. This what the cli will execute when this command is found.
@param value [Object] any object that implements :call @return [Object]
# File lib/fuelcell/action/callable.rb, line 9 def callable(value = nil) return @callable if value.nil? unless value.respond_to?(:call) fail ArgumentError, 'callable must implement :call' end @callable = value end
Also aliased as: run
callable?()
click to toggle source
# File lib/fuelcell/action/callable.rb, line 20 def callable? callable.respond_to?(:call) end
Also aliased as: runnable?
Protected Instance Methods
cast_exit_code(code)
click to toggle source
# File lib/fuelcell/action/callable.rb, line 42 def cast_exit_code(code) case code when 0...255 then code when nil, 0, '0', true then 0 when false, 1, '1' then 1 else fail "command #{name} execution return code #{code} could " \ 'not be interpreted as an exit code' end end