Class: RubyVolt::Response
- Inherits:
-
Object
- Object
- RubyVolt::Response
- Defined in:
- lib/ruby_volt/response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Response
constructor
A new instance of Response.
- #wrap(&block) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 11 |
# File 'lib/ruby_volt/response.rb', line 5 def initialize(*args) @bytes = case args[0] when ::IO, ReadPartial then args[0] else ReadPartial.new(args[0]) # Partial reader end @data = {} end |
Instance Attribute Details
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
3 4 5 |
# File 'lib/ruby_volt/response.rb', line 3 def bytes @bytes end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/ruby_volt/response.rb', line 3 def data @data end |
Instance Method Details
#wrap(&block) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/ruby_volt/response.rb', line 13 def wrap(&block) # data[:length] = DataType::Integer.unpack(bytes) # Message length data[:protocol] = DataType::Byte.unpack(bytes) # Protocol version yield self end |