class Crowbar::Client::Command::Base
Base
that provides methods shared between command implementations
Attributes
args[RW]
options[RW]
stderr[RW]
stdin[RW]
stdout[RW]
Public Class Methods
new(stdin, stdout, stderr, options = {}, args = {})
click to toggle source
# File lib/crowbar/client/command/base.rb, line 35 def initialize(stdin, stdout, stderr, options = {}, args = {}) self.stdin = stdin self.stdout = stdout self.stderr = stderr self.options = Hashie::Mash.new( options ) self.args = Hashie::Mash.new( args ) checks end
Protected Instance Methods
checks()
click to toggle source
# File lib/crowbar/client/command/base.rb, line 53 def checks end
err(message)
click to toggle source
# File lib/crowbar/client/command/base.rb, line 60 def err(message) if message.is_a?(RestClient::Response) begin json = JSON.parse(message.to_s) message = json.fetch("error", message) rescue JSON::ParserError # too bad, this is not what we expected, we'll print the ugly string nil end end raise SimpleCatchableError, message end
say(message)
click to toggle source
# File lib/crowbar/client/command/base.rb, line 56 def say(message) stdout.puts message end