Class: Htcp::Message::Header

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#encode_int16, #encode_int32, #encode_int8, #encode_string

Constructor Details

#initialize(params) ⇒ Header

Returns a new instance of Header.



6
7
8
9
10
11
12
13
# File 'lib/htcp/message/header.rb', line 6

def initialize(params)
  @params = {
    :major => 0,
    :minor => 0
  }.merge(params)

  @payload_len = 0
end

Instance Attribute Details

#payload_lenObject

Returns the value of attribute payload_len.



4
5
6
# File 'lib/htcp/message/header.rb', line 4

def payload_len
  @payload_len
end

Instance Method Details

#to_sObject



15
16
17
# File 'lib/htcp/message/header.rb', line 15

def to_s
  encode_int16(@payload_len + 4) + encode_int8(@params[:major], @params[:minor])
end