class DHCP::OptData
Class for DHCP options that contain data
Public Class Methods
new(opt, name, data=nil)
click to toggle source
Calls superclass method
DHCP::Opt.new
# File lib/dhcp/options.rb, line 35 def initialize(opt, name, data=nil) super(opt, name) @data = data.nil? ? '' : data_to_bin(data) end
Public Instance Methods
bin_to_data(data)
click to toggle source
# File lib/dhcp/options.rb, line 62 def bin_to_data(data) ## Override this in subclasses to interpret data data end
data()
click to toggle source
# File lib/dhcp/options.rb, line 40 def data @data end
data=(data)
click to toggle source
# File lib/dhcp/options.rb, line 44 def data=(data) @data = data.dup self ## Chainable end
data_to_bin(data)
click to toggle source
# File lib/dhcp/options.rb, line 58 def data_to_bin(data) ## Override this in subclasses to interpret data data end
get()
click to toggle source
# File lib/dhcp/options.rb, line 54 def get bin_to_data(@data) end
opt_header()
click to toggle source
Calls superclass method
DHCP::Opt#opt_header
# File lib/dhcp/options.rb, line 66 def opt_header super + "(#{data.size})" end
set(data)
click to toggle source
# File lib/dhcp/options.rb, line 49 def set(data) self.data = data_to_bin(data) self ## Chainable end
to_opt()
click to toggle source
Calls superclass method
DHCP::Opt#to_opt
# File lib/dhcp/options.rb, line 74 def to_opt super + @data.size.chr + @data end
to_s()
click to toggle source
# File lib/dhcp/options.rb, line 70 def to_s opt_header + "='#{bin_to_data(@data)}'" end