Class: RJR::Messages::Intermediate
- Defined in:
- lib/rjr/messages/intermediate.rb
Overview
Intermediate representation of a JSON-RPC data containing extracted/parsed data which has not been analysed.
Instance Attribute Summary collapse
-
#data ⇒ Object
Data extracted from message.
-
#json ⇒ Object
JSON from which data is extracted from.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #has?(key) ⇒ Boolean
-
#initialize(args = {}) ⇒ Intermediate
constructor
A new instance of Intermediate.
- #keys ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Intermediate
Returns a new instance of Intermediate.
21 22 23 24 |
# File 'lib/rjr/messages/intermediate.rb', line 21 def initialize(args = {}) @json = args[:json] || nil @data = args[:data] || {} end |
Instance Attribute Details
#data ⇒ Object
Data extracted from message
19 20 21 |
# File 'lib/rjr/messages/intermediate.rb', line 19 def data @data end |
#json ⇒ Object
JSON from which data is extracted from
16 17 18 |
# File 'lib/rjr/messages/intermediate.rb', line 16 def json @json end |
Class Method Details
.parse(json) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/rjr/messages/intermediate.rb', line 38 def self.parse(json) parsed = nil #allow parsing errs to propagate up parsed = JSONParser.parse(json) self.new :json => json, :data => parsed end |
Instance Method Details
#[](key) ⇒ Object
30 31 32 |
# File 'lib/rjr/messages/intermediate.rb', line 30 def [](key) data[key.to_s] end |
#has?(key) ⇒ Boolean
34 35 36 |
# File 'lib/rjr/messages/intermediate.rb', line 34 def has?(key) data.key?(key) end |
#keys ⇒ Object
26 27 28 |
# File 'lib/rjr/messages/intermediate.rb', line 26 def keys data.keys end |