Class: Rubtella::TCPData::Builder::Pong

Inherits:
Rubtella::TCPData::Builder show all
Defined in:
lib/rubtella/tcp_data.rb

Constant Summary

Constants included from Config

Config::GUID, Config::IP_ADDRESS, Config::PID_FILE, Config::PORT

Instance Attribute Summary collapse

Attributes inherited from Rubtella::TCPData::Base

#binary_data, #guid, #hops, #messages, #messages_codes, #payload_lenght, #payload_type, #rest, #ttl

Instance Method Summary collapse

Methods inherited from Rubtella::TCPData::Builder

#build, #init_messages_codes

Methods included from Config

generate_guid

Constructor Details

#initialize(args = nil) ⇒ Pong

Returns a new instance of Pong.



79
80
81
82
83
84
85
86
87
88
# File 'lib/rubtella/tcp_data.rb', line 79

def initialize args = nil
  super()

  @payload_type = @messages_codes["pong"]
  @port = build_port PORT
  @ip_address = build_ip IP_ADDRESS
  @files_amount = [0,0,0]
  @files_size = [0,0,0]

end

Instance Attribute Details

#ip_addressObject

Returns the value of attribute ip_address.



77
78
79
# File 'lib/rubtella/tcp_data.rb', line 77

def ip_address
  @ip_address
end

#portObject

Returns the value of attribute port.



77
78
79
# File 'lib/rubtella/tcp_data.rb', line 77

def port
  @port
end

Instance Method Details

#build_ip(ip_address) ⇒ Object



98
99
100
# File 'lib/rubtella/tcp_data.rb', line 98

def build_ip(ip_address)
  ip_address.split(".").collect {|b| b.to_i} # .pack("C*")
end

#build_messageObject



90
91
92
# File 'lib/rubtella/tcp_data.rb', line 90

def build_message
  @payload = [@port, @ip_address, @files_amount, @files_size]
end

#build_port(port) ⇒ Object



94
95
96
# File 'lib/rubtella/tcp_data.rb', line 94

def build_port(port)
  [port%256, port/256]# .pack("C*")
end