Class: Rubtella::TCPData::Builder::Pong
- Inherits:
-
Rubtella::TCPData::Builder
- Object
- Rubtella::TCPData::Base
- Rubtella::TCPData::Builder
- Rubtella::TCPData::Builder::Pong
- 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
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#port ⇒ Object
Returns the value of attribute port.
Attributes inherited from Rubtella::TCPData::Base
#binary_data, #guid, #hops, #messages, #messages_codes, #payload_lenght, #payload_type, #rest, #ttl
Instance Method Summary collapse
- #build_ip(ip_address) ⇒ Object
- #build_message ⇒ Object
- #build_port(port) ⇒ Object
-
#initialize(args = nil) ⇒ Pong
constructor
A new instance of Pong.
Methods inherited from Rubtella::TCPData::Builder
Methods included from Config
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_address ⇒ Object
Returns the value of attribute ip_address.
77 78 79 |
# File 'lib/rubtella/tcp_data.rb', line 77 def ip_address @ip_address end |
#port ⇒ Object
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_message ⇒ Object
90 91 92 |
# File 'lib/rubtella/tcp_data.rb', line 90 def @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 |