Class: RadiusRB::AttributesCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/radiusrb/dictionary/attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vendor = nil) ⇒ AttributesCollection

Returns a new instance of AttributesCollection.



7
8
9
10
11
# File 'lib/radiusrb/dictionary/attributes.rb', line 7

def initialize vendor=nil
  @collection = {}
  @revcollection = {}
  @vendor = vendor if vendor
end

Instance Attribute Details

#vendorObject

Returns the value of attribute vendor.



5
6
7
# File 'lib/radiusrb/dictionary/attributes.rb', line 5

def vendor
  @vendor
end

Instance Method Details

#add(name, id, type) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/radiusrb/dictionary/attributes.rb', line 13

def add(name, id, type)
  if vendor?
    @collection[name] ||= Attribute.new(name, id.to_i, type, @vendor)
  else
    @collection[name] ||= Attribute.new(name, id.to_i, type)
  end
  @revcollection[id.to_i] ||= @collection[name]
  self << @collection[name]
end

#find_by_id(id) ⇒ Object



27
28
29
# File 'lib/radiusrb/dictionary/attributes.rb', line 27

def find_by_id(id)
  @revcollection[id]
end

#find_by_name(name) ⇒ Object



23
24
25
# File 'lib/radiusrb/dictionary/attributes.rb', line 23

def find_by_name(name)
  @collection[name]
end

#vendor?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/radiusrb/dictionary/attributes.rb', line 31

def vendor?
  !!@vendor
end