Sha256: 5c8849c7c838aa65ad2cfdf1a76b60a70a9f6728739181016e11abc394e158ee

Contents?: true

Size: 421 Bytes

Versions: 6

Compression:

Stored size: 421 Bytes

Contents

# encoding: utf-8

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)
        self.octets = value.to_a
      end

      def get
        Mac.new(octets.reduce('') do |str, each|
                  str + format('%02x', each)
                end.hex)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pio-0.8.1 lib/pio/type/mac_address.rb
pio-0.8.0 lib/pio/type/mac_address.rb
pio-0.7.0 lib/pio/type/mac_address.rb
pio-0.6.0 lib/pio/type/mac_address.rb
pio-0.5.0 lib/pio/type/mac_address.rb
pio-0.4.0 lib/pio/type/mac_address.rb