Sha256: 7dbea602cb5bed7bef749fdb930754765fb96f70c15e6eff56f5a020a903b713

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 Bytes

Contents

# frozen_string_literal: true

require 'bindata'

module Pio
  module Type
    # Ether type
    class EtherType < BinData::Primitive
      endian :big

      uint16 :ether_type

      def set(value)
        self.ether_type = value
      end

      def get
        ether_type
      end

      # This method smells of :reek:UncommunicativeVariableName
      def to_bytes
        byte1 = format('%02x', (self & 0xff00) >> 8)
        byte2 = format('%02x', self & 0xff)
        "0x#{byte1}, 0x#{byte2}"
      end

      def inspect
        Kernel.format '0x%04x', self
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.30.2 lib/pio/type/ether_type.rb