Class: Lib::BOOTP::Packet::ServerHostName

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sname = '.') ⇒ ServerHostName

Returns a new instance of ServerHostName.

Raises:

  • (ArgumentError)


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

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

Class Method Details

.unpack(packet) ⇒ Object



31
32
33
# File 'lib/lib/bootp/packet/server_host_name.rb', line 31

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

Instance Method Details

#<=>(other) ⇒ Object



23
24
25
# File 'lib/lib/bootp/packet/server_host_name.rb', line 23

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

#packObject



27
28
29
# File 'lib/lib/bootp/packet/server_host_name.rb', line 27

def pack
  [@sname].pack('a64')
end