Class: UDPRest::UDPPacket

Inherits:
Object
  • Object
show all
Defined in:
lib/udp_rest/udp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ UDPPacket

Returns a new instance of UDPPacket.



55
56
57
58
59
60
61
62
63
64
# File 'lib/udp_rest/udp.rb', line 55

def initialize(data = nil)
    # assume this was initialized with the standard data structure
    # that is returned by UDPSocket
    if !data.nil?
        self.text = data[0]
        self.addr_family = data[1][0]
        self.src_port = data[1][1]
        self.src_addr = data[1][2]
    end
end

Instance Attribute Details

#addr_familyObject

Returns the value of attribute addr_family.



51
52
53
# File 'lib/udp_rest/udp.rb', line 51

def addr_family
  @addr_family
end

#src_addrObject

Returns the value of attribute src_addr.



53
54
55
# File 'lib/udp_rest/udp.rb', line 53

def src_addr
  @src_addr
end

#src_portObject

Returns the value of attribute src_port.



52
53
54
# File 'lib/udp_rest/udp.rb', line 52

def src_port
  @src_port
end

#textObject

Returns the value of attribute text.



50
51
52
# File 'lib/udp_rest/udp.rb', line 50

def text
  @text
end

Instance Method Details

#to_sObject



66
67
68
# File 'lib/udp_rest/udp.rb', line 66

def to_s
    self.text
end