Class: Bixby::CommandResponse

Inherits:
Object
  • Object
show all
Includes:
Jsonify
Defined in:
lib/bixby_common/command_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Jsonify

included, #to_json

Methods included from Hashify

#to_hash

Constructor Details

#initialize(params = nil) ⇒ CommandResponse

Returns a new instance of CommandResponse.



9
10
11
12
# File 'lib/bixby_common/command_response.rb', line 9

def initialize(params = nil)
  return if params.nil? or params.empty?
  params.each{ |k,v| self.send("#{k}=", v) if self.respond_to? "#{k}=" }
end

Instance Attribute Details

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/bixby_common/command_response.rb', line 7

def status
  @status
end

#stderrObject

Returns the value of attribute stderr.



7
8
9
# File 'lib/bixby_common/command_response.rb', line 7

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout.



7
8
9
# File 'lib/bixby_common/command_response.rb', line 7

def stdout
  @stdout
end

Instance Method Details

#decodeObject



22
23
24
# File 'lib/bixby_common/command_response.rb', line 22

def decode
  MultiJson.load(@stdout)
end

#decode_stderrObject



26
27
28
# File 'lib/bixby_common/command_response.rb', line 26

def decode_stderr
  MultiJson.load(@stderr)
end

#error?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/bixby_common/command_response.rb', line 18

def error?
  not success?
end

#success?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/bixby_common/command_response.rb', line 14

def success?
  @status.to_i == 0
end