Class: Lib::BOOTP::Packet::BootFile

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = '.') ⇒ BootFile

Returns a new instance of BootFile.

Raises:

  • (ArgumentError)


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

def initialize(file = '.')
  raise ArgumentError, "Can't convert #{file.class.name} to String" unless file.respond_to? :to_s
  raise ArgumentError, "Given Server Host Name is to long: #{file}" if file.to_s.size > 128
  @file = file.to_s
end

Class Method Details

.unpack(packet) ⇒ Object



32
33
34
# File 'lib/lib/bootp/packet/boot_file.rb', line 32

def self.unpack(packet)
  new packet.unpack('a128').first.to_s
end

Instance Method Details

#<=>(other) ⇒ Object



24
25
26
# File 'lib/lib/bootp/packet/boot_file.rb', line 24

def <=>(other)
  self.to_s <=> other.to_s
end

#packObject



28
29
30
# File 'lib/lib/bootp/packet/boot_file.rb', line 28

def pack
  [@file].pack('a128')
end