Sha256: a583722193639d76530dd3518a991b7cbb22d0661dc538b731bb4adbee2a3586
Contents?: true
Size: 542 Bytes
Versions: 2
Compression:
Stored size: 542 Bytes
Contents
require 'bindata' require 'pio/mac' module Pio module Type # MAC address class MacAddress < BinData::Primitive array :octets, type: :uint8, initial_length: 6 def set(value) case value when String self.octets = value.split(':').map { |each| ('0x' + each).hex } else self.octets = value.to_a end end def get Mac.new(octets.reduce('') do |str, each| str + format('%02x', each) end.hex) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pio-0.9.0 | lib/pio/type/mac_address.rb |
pio-0.8.2 | lib/pio/type/mac_address.rb |