Class: RubyVolt::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_volt/response.rb

Direct Known Subclasses

InvocationResponse, LoginResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bytesObject (readonly)

Returns the value of attribute bytes.



3
4
5
# File 'lib/ruby_volt/response.rb', line 3

def bytes
  @bytes
end

#dataObject (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