Class: ReverseParameters::BaseCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/reverse_parameters.rb

Direct Known Subclasses

Arguments, Parameters

Defined Under Namespace

Classes: Item

Instance Method Summary collapse

Constructor Details

#initialize(collection, **options) ⇒ BaseCollection

Returns a new instance of BaseCollection.



42
43
44
# File 'lib/reverse_parameters.rb', line 42

def initialize(collection, **options)
  @collection = collection.map { |state, name| item_class.new(state: state, name: name, **options) }
end

Instance Method Details

#each(&block) ⇒ Object



46
47
48
# File 'lib/reverse_parameters.rb', line 46

def each(&block)
  @collection.send(:each, &block)
end

#to_aObject



54
55
56
# File 'lib/reverse_parameters.rb', line 54

def to_a
  map(&:to_s)
end

#to_sObject



50
51
52
# File 'lib/reverse_parameters.rb', line 50

def to_s
  to_a.join(', ')
end