I have a method that should take 1+ parameters of any class, similar to Array#push:
def my_push(*objects)
raise ArgumentError, 'Needs 1+ arguments' if objects.empty?
objects.each do |obj|
puts "An object was pushed: #{obj.inspect}"
@my_array.push obj
end
end
What is the best way to document the method parameters using YARD syntax?
Edit:
I realize that my original question was a bit too vague and didn't quite specify what I was looking for.
A better question would be, what is the best way to specify the arity of a method (1-∞ in this case) in YARD when using a splatted parameter? I know I could just specify it in the text, but it seems like there should be a tag or something similar to specify arity.
Array<Object>
is that it implies that an empty list of params is acceptable.@overload
seems like it is more for specifying different method invocations that have vastly different types of parameters. – Polygamous