Class: Dashed::Packet
- Inherits:
-
Object
- Object
- Dashed::Packet
- Defined in:
- lib/dashed/packet.rb
Instance Attribute Summary collapse
-
#raw_packet ⇒ Object
readonly
Returns the value of attribute raw_packet.
Instance Method Summary collapse
- #host_mac_address ⇒ Object
-
#initialize(raw_packet) ⇒ Packet
constructor
A new instance of Packet.
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_packet ⇒ Object (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_address ⇒ Object
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 |