lib/reverse_parameters.rb in reverse_parameters-0.2.0 vs lib/reverse_parameters.rb in reverse_parameters-0.3.0

- old
+ new

@@ -30,11 +30,11 @@ class BaseCollection include Enumerable def initialize(collection) - @collection = collection.map{|state, name| item_class.new(state: state, name: name)} + @collection = collection.map { |state, name| item_class.new(state: state, name: name) } end def each(&block) @collection.send(:each, &block) end @@ -50,20 +50,23 @@ class Item def initialize(name:, state:) @name = name @state = state end + attr_reader :name, :state end end class Arguments < BaseCollection; class Arg < BaseCollection::Item def to_s case state when :key, :keyreq "#{name}: #{name}" + when :block + "&#{name}" else name end.to_s end end @@ -86,9 +89,11 @@ "#{name}=nil" when :keyreq "#{name}:" when :key "#{name}: nil" + when :block + "&#{name}" end.to_s end end def item_class