Class: Radiustar::ValuesCollection
- Inherits:
-
Object
- Object
- Radiustar::ValuesCollection
- Defined in:
- lib/radiustar/dictionary/values.rb
Instance Method Summary collapse
- #add(name, id) ⇒ Object
- #empty? ⇒ Boolean
- #find_by_id(id) ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize ⇒ ValuesCollection
constructor
A new instance of ValuesCollection.
Constructor Details
#initialize ⇒ ValuesCollection
Returns a new instance of ValuesCollection.
5 6 7 8 |
# File 'lib/radiustar/dictionary/values.rb', line 5 def initialize @collection = {} @revcollection = [] end |
Instance Method Details
#add(name, id) ⇒ Object
10 11 12 13 |
# File 'lib/radiustar/dictionary/values.rb', line 10 def add(name, id) @collection[name] ||= Value.new(name, id) @revcollection[id.to_i] ||= @collection[name] end |
#empty? ⇒ Boolean
23 24 25 |
# File 'lib/radiustar/dictionary/values.rb', line 23 def empty? @collection.empty? end |
#find_by_id(id) ⇒ Object
19 20 21 |
# File 'lib/radiustar/dictionary/values.rb', line 19 def find_by_id(id) @revcollection[id] end |
#find_by_name(name) ⇒ Object
15 16 17 |
# File 'lib/radiustar/dictionary/values.rb', line 15 def find_by_name(name) @collection[name] end |