Class: MiOS::CategoryCollection
- Inherits:
-
Object
- Object
- MiOS::CategoryCollection
- Defined in:
- lib/mios/category_collection.rb
Instance Method Summary collapse
- #all ⇒ Object
- #find_by_id(id) ⇒ Object
- #find_by_label(label) ⇒ Object
-
#initialize(filters) ⇒ CategoryCollection
constructor
A new instance of CategoryCollection.
- #to_s ⇒ Object
Constructor Details
#initialize(filters) ⇒ CategoryCollection
Returns a new instance of CategoryCollection.
4 5 6 7 8 9 |
# File 'lib/mios/category_collection.rb', line 4 def initialize(filters) @filters = filters @categories = @filters.each_with_object([]) do |filter, categories| categories << Category.new(label_for(filter), category_nums_for(filter)) end end |
Instance Method Details
#all ⇒ Object
11 12 13 |
# File 'lib/mios/category_collection.rb', line 11 def all @categories end |
#find_by_id(id) ⇒ Object
15 16 17 |
# File 'lib/mios/category_collection.rb', line 15 def find_by_id(id) @categories.find { |c| c.ids.include? id } end |
#find_by_label(label) ⇒ Object
19 20 21 |
# File 'lib/mios/category_collection.rb', line 19 def find_by_label(label) @categories.find { |c| c.label == label } end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/mios/category_collection.rb', line 23 def to_s @categories.to_s end |