Class: JSONRPCOverMQTT::JSONRPC::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/json_rpc_over_mqtt_example/json_rpc/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Request

Returns a new instance of Request.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/json_rpc_over_mqtt_example/json_rpc/request.rb', line 8

def initialize(message)
  json_rpc_obj = JSON.parse(message)
  @id = json_rpc_obj["id"]
  @method = json_rpc_obj["method"]

  if json_rpc_obj["params"].nil?
    @params = nil
  else
    @params = Hash[json_rpc_obj["params"].map{ |k,v| [k.to_sym, v] }]
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/json_rpc_over_mqtt_example/json_rpc/request.rb', line 6

def id
  @id
end

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/json_rpc_over_mqtt_example/json_rpc/request.rb', line 6

def method
  @method
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/json_rpc_over_mqtt_example/json_rpc/request.rb', line 6

def params
  @params
end