Class: ReverseParameters::BaseCollection
- Inherits:
-
Object
- Object
- ReverseParameters::BaseCollection
- Includes:
- Enumerable
- Defined in:
- lib/reverse_parameters.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Item
Instance Method Summary collapse
- #[](value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(collection, **options) ⇒ BaseCollection
constructor
A new instance of BaseCollection.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(collection, **options) ⇒ BaseCollection
Returns a new instance of BaseCollection.
53 54 55 |
# File 'lib/reverse_parameters.rb', line 53 def initialize(collection, **) @collection = collection.map { |state, name| item_class.new(state: state, name: name, **) } end |
Instance Method Details
#[](value) ⇒ Object
69 70 71 |
# File 'lib/reverse_parameters.rb', line 69 def [](value) @collection[value] end |
#each(&block) ⇒ Object
57 58 59 |
# File 'lib/reverse_parameters.rb', line 57 def each(&block) @collection.send(:each, &block) end |
#to_a ⇒ Object
65 66 67 |
# File 'lib/reverse_parameters.rb', line 65 def to_a map(&:to_s) end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/reverse_parameters.rb', line 61 def to_s to_a.join(', ') end |