Class: Vici::Message
- Inherits:
-
Object
- Object
- Vici::Message
- Defined in:
- lib/vici.rb
Overview
The Message class provides the low level encoding and decoding of vici protocol messages. Directly using this class is usually not required.
Constant Summary collapse
- SECTION_START =
1- SECTION_END =
2- KEY_VALUE =
3- LIST_START =
4- LIST_ITEM =
5- LIST_END =
6
Instance Method Summary collapse
-
#encoding ⇒ Object
Get the raw byte encoding of an on-the-wire message.
-
#initialize(data = "") ⇒ Message
constructor
A new instance of Message.
-
#root ⇒ Object
Get the root element of the parsed ruby data structures.
Constructor Details
#initialize(data = "") ⇒ Message
Returns a new instance of Message.
89 90 91 92 93 94 95 96 97 |
# File 'lib/vici.rb', line 89 def initialize(data = "") if data.nil? @root = {} elsif data.is_a?(Hash) @root = data else @encoded = data end end |
Instance Method Details
#encoding ⇒ Object
Get the raw byte encoding of an on-the-wire message
101 102 103 104 |
# File 'lib/vici.rb', line 101 def encoding @encoded = encode(@root) if @encoded.nil? @encoded end |
#root ⇒ Object
Get the root element of the parsed ruby data structures
108 109 110 111 |
# File 'lib/vici.rb', line 108 def root @root = parse(@encoded) if @root.nil? @root end |