Class: DHCP::OptData
Overview
Class for DHCP options that contain data
Direct Known Subclasses
OptDomain, OptFixedData, OptHexString, OptHost, OptListData, SubOpt
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Attributes inherited from Opt
Instance Method Summary collapse
-
#bin_to_data(data) ⇒ Object
Override this in subclasses to interpret data.
-
#data_to_bin(data) ⇒ Object
Override this in subclasses to interpret data.
- #get ⇒ Object
-
#initialize(opt, name, data = nil) ⇒ OptData
constructor
A new instance of OptData.
- #opt_header ⇒ Object
- #set(data) ⇒ Object
- #to_opt ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(opt, name, data = nil) ⇒ OptData
Returns a new instance of OptData.
67 68 69 70 |
# File 'lib/dhcp/options.rb', line 67 def initialize(opt, name, data=nil) super(opt, name) @data = data.nil? ? '' : data_to_bin(data) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
71 72 73 |
# File 'lib/dhcp/options.rb', line 71 def data @data end |
Instance Method Details
#bin_to_data(data) ⇒ Object
Override this in subclasses to interpret data
95 96 97 |
# File 'lib/dhcp/options.rb', line 95 def bin_to_data(data) ## Override this in subclasses to interpret data data end |
#data_to_bin(data) ⇒ Object
Override this in subclasses to interpret data
91 92 93 |
# File 'lib/dhcp/options.rb', line 91 def data_to_bin(data) ## Override this in subclasses to interpret data data end |
#get ⇒ Object
87 88 89 |
# File 'lib/dhcp/options.rb', line 87 def get bin_to_data(@data) end |
#opt_header ⇒ Object
99 100 101 |
# File 'lib/dhcp/options.rb', line 99 def opt_header super + "(#{data.size})" end |
#set(data) ⇒ Object
82 83 84 85 |
# File 'lib/dhcp/options.rb', line 82 def set(data) self.data = data_to_bin(data) self ## Chainable end |
#to_opt ⇒ Object
107 108 109 |
# File 'lib/dhcp/options.rb', line 107 def to_opt super + @data.size.chr + @data end |
#to_s ⇒ Object
103 104 105 |
# File 'lib/dhcp/options.rb', line 103 def to_s opt_header + "='#{bin_to_data(@data)}'" end |