lib/reverse_parameters.rb in reverse_parameters-1.1.0 vs lib/reverse_parameters.rb in reverse_parameters-1.1.1
- old
+ new
@@ -14,10 +14,12 @@
def initialize(input)
if input.respond_to?(:to_proc)
@params = input.to_proc.parameters
elsif input.respond_to?(:to_ary)
@params = input.to_ary
+ elsif input.is_a? UnboundMethod
+ @params = input.parameters
else
raise ArgumentError.new("Input must be an Array of parameters or a Proc object.")
end
end
@@ -62,10 +64,14 @@
def to_a
map(&:to_s)
end
+ def [](value)
+ @collection[value]
+ end
+
class Item
def initialize(name:, state:, **options)
@name = name
@state = state
post_initialize(options)
@@ -83,9 +89,13 @@
class Arg < BaseCollection::Item
def to_s
case state
when :key, :keyreq
"#{name}: #{name}"
+ when :keyrest
+ "**#{name}"
+ when :rest
+ "*#{name}"
when :block
block(name)
else
name
end.to_s