Class: DHCP::OptFixedData
Overview
Class for DHCP options containing a fixed number of bytes
Class Attribute Summary collapse
-
.size ⇒ Object
Returns the value of attribute size.
Attributes inherited from OptData
Attributes inherited from Opt
Instance Method Summary collapse
- #data=(data) ⇒ Object
-
#initialize(opt, name, data = nil) ⇒ OptFixedData
constructor
A new instance of OptFixedData.
Methods inherited from OptData
#bin_to_data, #data_to_bin, #get, #opt_header, #set, #to_opt, #to_s
Methods inherited from Opt
Constructor Details
#initialize(opt, name, data = nil) ⇒ OptFixedData
Returns a new instance of OptFixedData.
120 121 122 123 124 |
# File 'lib/dhcp/options.rb', line 120 def initialize(opt, name, data=nil) super(opt, name, data) ## Prefill with zeros if needed: @data = 0.chr * self.class.size if data.nil? && self.class.size > 0 end |
Class Attribute Details
.size ⇒ Object
Returns the value of attribute size.
117 118 119 |
# File 'lib/dhcp/options.rb', line 117 def size @size end |
Instance Method Details
#data=(data) ⇒ Object
126 127 128 129 |
# File 'lib/dhcp/options.rb', line 126 def data=(data) raise "Invalid size for #{self.class} (expected #{size} bytes, not #{data.size} bytes)" unless self.class.size == data.size super(data) end |