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.



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

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.



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

def id
  @id
end

#lengthObject

Returns the value of attribute length.



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

def length
  @length
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#targetObject

Returns the value of attribute target.



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

def target
  @target
end

Instance Method Details

#inspectObject



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

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

#ok?Boolean

Returns:

  • (Boolean)


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

def ok?
  status == 200
end