Class: XRBP::WebSocket::Command
- Defined in:
- lib/xrbp/websocket/command.rb
Direct Known Subclasses
XRBP::WebSocket::Cmds::AccountInfo, XRBP::WebSocket::Cmds::AccountLines, XRBP::WebSocket::Cmds::AccountObjects, XRBP::WebSocket::Cmds::AccountOffers, XRBP::WebSocket::Cmds::AccountTx, XRBP::WebSocket::Cmds::BookOffers, XRBP::WebSocket::Cmds::Ledger, XRBP::WebSocket::Cmds::LedgerEntry, XRBP::WebSocket::Cmds::ServerInfo, XRBP::WebSocket::Cmds::Subscribe
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
Attributes inherited from Message
#bl, #connection, #result, #time
Instance Method Summary collapse
-
#initialize(data) ⇒ Command
constructor
A new instance of Command.
- #requesting ⇒ Object
- #requesting?(tgt) ⇒ Boolean
Methods inherited from Message
Constructor Details
#initialize(data) ⇒ Command
Returns a new instance of Command.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/xrbp/websocket/command.rb', line 7 def initialize(data) @@id ||= 0 @id = (@@id += 1) json = Hash[data] json['id'] = id @json = json super(json.to_json) end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/xrbp/websocket/command.rb', line 4 def id @id end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
5 6 7 |
# File 'lib/xrbp/websocket/command.rb', line 5 def json @json end |
Instance Method Details
#requesting ⇒ Object
19 20 21 |
# File 'lib/xrbp/websocket/command.rb', line 19 def requesting @json[:command] || @json["command"] end |
#requesting?(tgt) ⇒ Boolean
23 24 25 |
# File 'lib/xrbp/websocket/command.rb', line 23 def requesting?(tgt) requesting.to_s == tgt.to_s end |