Class: RadiusRB::Packet::Attribute
- Inherits:
-
Object
- Object
- RadiusRB::Packet::Attribute
- Defined in:
- lib/radiusrb/packet.rb
Instance Attribute Summary collapse
-
#dict ⇒ Object
readonly
Returns the value of attribute dict.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
-
#vendor ⇒ Object
readonly
Returns the value of attribute vendor.
Instance Method Summary collapse
-
#initialize(dict, name, value, vendor = nil) ⇒ Attribute
constructor
A new instance of Attribute.
- #inspect ⇒ Object
- #pack ⇒ Object
- #to_s ⇒ Object
- #vendor? ⇒ Boolean
Constructor Details
#initialize(dict, name, value, vendor = nil) ⇒ Attribute
Returns a new instance of Attribute.
229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/radiusrb/packet.rb', line 229 def initialize dict, name, value, vendor=nil @dict = dict # This is the cheapest and easiest way to add VSA's! if (name && (chunks = name.split('/')) && (chunks.size == 2)) @vendor = chunks[0] @name = chunks[1] else @name = name end @vendor ||= vendor @value = value.is_a?(Attribute) ? value.to_s : value end |
Instance Attribute Details
#dict ⇒ Object (readonly)
Returns the value of attribute dict.
226 227 228 |
# File 'lib/radiusrb/packet.rb', line 226 def dict @dict end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
226 227 228 |
# File 'lib/radiusrb/packet.rb', line 226 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
227 228 229 |
# File 'lib/radiusrb/packet.rb', line 227 def value @value end |
#vendor ⇒ Object (readonly)
Returns the value of attribute vendor.
226 227 228 |
# File 'lib/radiusrb/packet.rb', line 226 def vendor @vendor end |
Instance Method Details
#inspect ⇒ Object
261 262 263 |
# File 'lib/radiusrb/packet.rb', line 261 def inspect @value end |
#pack ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/radiusrb/packet.rb', line 246 def pack attribute = if (vendor? && (@dict.vendors.find_by_name(@vendor))) @dict.vendors.find_by_name(@vendor).attributes.find_by_name(@name) else @dict.find_attribute_by_name(@name) end raise "Undefined attribute '#{@name}'." if attribute.nil? if vendor? pack_vendor_specific_attribute attribute else pack_attribute attribute end end |
#to_s ⇒ Object
265 266 267 |
# File 'lib/radiusrb/packet.rb', line 265 def to_s @value end |
#vendor? ⇒ Boolean
242 243 244 |
# File 'lib/radiusrb/packet.rb', line 242 def vendor? !!@vendor end |