Class: Warchat::Network::Response

Inherits:
Hash
  • Object
show all
Defined in:
lib/warchat/network/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket, *args) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
11
12
13
14
# File 'lib/warchat/network/response.rb', line 5

def initialize socket,*args
  super *args
  reader = BinaryReader.new socket
  self.length = reader.int_32
  self.status = reader.int_16
  self.target = reader.string
  self.id = reader.int_32

  merge! reader.parse_next
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/warchat/network/response.rb', line 4

def id
  @id
end

#lengthObject

Returns the value of attribute length.



4
5
6
# File 'lib/warchat/network/response.rb', line 4

def length
  @length
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/warchat/network/response.rb', line 4

def status
  @status
end

#targetObject

Returns the value of attribute target.



4
5
6
# File 'lib/warchat/network/response.rb', line 4

def target
  @target
end

Instance Method Details

#inspectObject



20
21
22
# File 'lib/warchat/network/response.rb', line 20

def inspect
  "<#{self.class.name} id:#{id.inspect} target:#{target.inspect} status:#{status.inspect} #{super}>"
end

#ok?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/warchat/network/response.rb', line 16

def ok?
  status == 200
end