Class: Pio::Type::EtherType

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/pio/type/ether_type.rb

Overview

Ether type

Instance Method Summary collapse

Instance Method Details

#getObject



17
18
19
# File 'lib/pio/type/ether_type.rb', line 17

def get
  ether_type
end

#inspectObject



28
29
30
# File 'lib/pio/type/ether_type.rb', line 28

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

#set(value) ⇒ Object



13
14
15
# File 'lib/pio/type/ether_type.rb', line 13

def set(value)
  self.ether_type = value
end

#to_bytesObject

This method smells of :reek:UncommunicativeVariableName



22
23
24
25
26
# File 'lib/pio/type/ether_type.rb', line 22

def to_bytes
  byte1 = format('%02x', (self & 0xff00) >> 8)
  byte2 = format('%02x', self & 0xff)
  "0x#{byte1}, 0x#{byte2}"
end