module MuchStub::ParameterList

Constants

LETTERS

Public Class Methods

build_params_from_arity(arity) click to toggle source
# File lib/much-stub.rb, line 291
def self.build_params_from_arity(arity)
  number = arity < 0 ? (arity + 1).abs : arity
  (0..(number - 1)).map{ |param_index| get_param_name(param_index) }
end
get_arity(object, method_name) click to toggle source
# File lib/much-stub.rb, line 285
def self.get_arity(object, method_name)
  object.method(method_name).arity
rescue NameError
  -1
end
get_param_name(param_index) click to toggle source
# File lib/much-stub.rb, line 296
def self.get_param_name(param_index)
  param_index += LETTERS.size # avoid getting 0 for the number of letters
  number_of_letters, letter_index = param_index.divmod(LETTERS.size)
  LETTERS[letter_index] * number_of_letters
end
new(object, method_name) click to toggle source
# File lib/much-stub.rb, line 277
def self.new(object, method_name)
  arity = get_arity(object, method_name)
  params = build_params_from_arity(arity)
  params << "*pargs, **kargs" if arity < 0
  params << "&block"
  params.join(", ")
end