Class: Msf::RPC::JSON::Response
- Inherits:
-
Object
- Object
- Msf::RPC::JSON::Response
- Defined in:
- lib/msf/core/rpc/json/response.rb
Overview
Represents a JSON-RPC response.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
-
.parse(response, symbolize_names: true) ⇒ Response
Parse response and return a new Response instance.
Instance Method Summary collapse
-
#initialize(id:, result:, response: nil) ⇒ Response
constructor
Instantiate a Response object.
Constructor Details
#initialize(id:, result:, response: nil) ⇒ Response
Instantiate a Response object.
31 32 33 34 35 |
# File 'lib/msf/core/rpc/json/response.rb', line 31 def initialize(id:, result:, response: nil) @id = id @result = result @response = response end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/msf/core/rpc/json/response.rb', line 6 def id @id end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/msf/core/rpc/json/response.rb', line 5 def response @response end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
7 8 9 |
# File 'lib/msf/core/rpc/json/response.rb', line 7 def result @result end |
Class Method Details
.parse(response, symbolize_names: true) ⇒ Response
Parse response and return a new Response instance.
14 15 16 17 18 19 20 21 22 |
# File 'lib/msf/core/rpc/json/response.rb', line 14 def self.parse(response, symbolize_names: true) id_key = symbolize_names ? :id : :id.to_s result_key = symbolize_names ? :result : :result.to_s id = response[id_key] result = response[result_key] Response.new(id: id, result: result, response: response) end |