Class: Radiustar::Packet::Attribute
- Inherits:
-
Object
- Object
- Radiustar::Packet::Attribute
- Defined in:
- lib/radiustar/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.
212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/radiustar/packet.rb', line 212 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.
209 210 211 |
# File 'lib/radiustar/packet.rb', line 209 def dict @dict end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
209 210 211 |
# File 'lib/radiustar/packet.rb', line 209 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
210 211 212 |
# File 'lib/radiustar/packet.rb', line 210 def value @value end |
#vendor ⇒ Object (readonly)
Returns the value of attribute vendor.
209 210 211 |
# File 'lib/radiustar/packet.rb', line 209 def vendor @vendor end |
Instance Method Details
#inspect ⇒ Object
244 245 246 |
# File 'lib/radiustar/packet.rb', line 244 def inspect @value end |
#pack ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/radiustar/packet.rb', line 229 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
248 249 250 |
# File 'lib/radiustar/packet.rb', line 248 def to_s @value end |
#vendor? ⇒ Boolean
225 226 227 |
# File 'lib/radiustar/packet.rb', line 225 def vendor? !!@vendor end |