Class: Dashed::Packet

Inherits:
Object
  • Object
show all
Defined in:
lib/dashed/packet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_packet) ⇒ Packet

Returns a new instance of Packet.



5
6
7
# File 'lib/dashed/packet.rb', line 5

def initialize(raw_packet)
  @raw_packet = raw_packet
end

Instance Attribute Details

#raw_packetObject (readonly)

Returns the value of attribute raw_packet.



3
4
5
# File 'lib/dashed/packet.rb', line 3

def raw_packet
  @raw_packet
end

Instance Method Details

#host_mac_addressObject



9
10
11
12
13
14
15
16
17
# File 'lib/dashed/packet.rb', line 9

def host_mac_address
  raw_packet.
    data.
    unpack("C*").
    map { |i| i.to_s(16) }.
    map { |i| if i.length == 1 then "0#{i}" else i end}.
    slice(6, 6).
    join(":")
end