Class: Lib::BOOTP::Packet::HardwareAddressType

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Comparable
Defined in:
lib/lib/bootp/packet/hardware_address_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(htype = 1) ⇒ HardwareAddressType

Returns a new instance of HardwareAddressType.

Raises:

  • (ArgumentError)


18
19
20
21
# File 'lib/lib/bootp/packet/hardware_address_type.rb', line 18

def initialize(htype=1)
  raise ArgumentError, "Hardware address type out of range : #{htype}" unless (0..12).include? htype
  @htype = htype
end

Class Method Details

.unpack(htype) ⇒ Object



71
72
73
# File 'lib/lib/bootp/packet/hardware_address_type.rb', line 71

def self.unpack(htype)
  self.new htype.unpack('C').first
end

Instance Method Details

#<=>(other) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/lib/bootp/packet/hardware_address_type.rb', line 56

def <=>(other)
  case other
    when String
      self.to_s <=> other
    when Integer
      self.to_i <=> other
    else
      self.to_i <=> other.to_i
  end
end

#packObject



67
68
69
# File 'lib/lib/bootp/packet/hardware_address_type.rb', line 67

def pack
  [@htype.to_i].pack('C')
end

#to_sObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/lib/bootp/packet/hardware_address_type.rb', line 23

def to_s
  case @htype
    when 0
      'Lease Query'
    when 1
      'Ethernet (10Mb)'
    when 2
      'Experimental Ethernet (3Mb)'
    when 3
      'Amateur Radio AX.25'
    when 4
      'Proteon ProNET Token Ring'
    when 5
      'Chaos'
    when 6
      'IEEE 802 Networks'
    when 7
      'ARCNET'
    when 8
      'Hyperchannel'
    when 9
      'Lanstar'
    when 10
      'Autonet Short Address'
    when 11
      'LocalTalk'
    when 12
      'LocalNet (IBM PCNet or SYTEK LocalNET)'
    else
      raise ArgumentError, "Hardware address type out of range : #{@htype}"
  end
end