Class: Htcp::Message::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/htcp/message/base.rb

Direct Known Subclasses

Auth, Data, Header, OpData::Clr, Specifier

Instance Method Summary collapse

Instance Method Details

#encode_int16(*ints) ⇒ Object

Put 16-bit int(s) to request.



12
13
14
15
16
# File 'lib/htcp/message/base.rb', line 12

def encode_int16(*ints)
  request = ''
  ints.each { |i| request << [i].pack('n') }
  return request
end

#encode_int32(*ints) ⇒ Object

Put 32-bit int(s) to request.



19
20
21
22
23
# File 'lib/htcp/message/base.rb', line 19

def encode_int32(*ints)
  request = ''
  ints.each { |i| request << [i].pack('N') }
  return request
end

#encode_int8(*ints) ⇒ Object

Put 16-bit int(s) to request.



5
6
7
8
9
# File 'lib/htcp/message/base.rb', line 5

def encode_int8(*ints)
  request = ''
  ints.each { |i| request << [i].pack('C') }
  return request
end

#encode_string(*strings) ⇒ Object

Put string(s) to request (first length, then the string itself).



26
27
28
29
30
# File 'lib/htcp/message/base.rb', line 26

def encode_string(*strings)
  request = ''
  strings.each { |s| request << encode_int16(s.length) + s }
  return request
end