Class: Rubtella::TCPData::Builder
Defined Under Namespace
Constant Summary
Constants included from Config
Config::GUID, Config::IP_ADDRESS, Config::PID_FILE, Config::PORT
Instance Attribute Summary
Attributes inherited from Base
#binary_data, #guid, #hops, #messages, #messages_codes, #payload_lenght, #payload_type, #rest, #ttl
Instance Method Summary collapse
- #build ⇒ Object
- #build_message ⇒ Object
- #init_messages_codes ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
Methods included from Config
Constructor Details
Instance Method Details
#build ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubtella/tcp_data.rb', line 48 def build @data = Array.new @guid = GUID @payload_length = @payload.length @data = [@guid, @payload_type, @ttl, @hops, @payload_length, @payload] @binary_data = @data.flatten.pack("C*") @binary_data end |
#build_message ⇒ Object
61 62 63 64 |
# File 'lib/rubtella/tcp_data.rb', line 61 def # this method needs to be implemented by a child class @payload = [] end |
#init_messages_codes ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/rubtella/tcp_data.rb', line 27 def @messages_codes = {"ping" => 0, "pong" => 1, "push" => 64, "query" => 128, "query_hit" =>129} @messages_codes.default = "Unknown Payload Type" end |