Class: Sinclair::MethodDefinition::ParameterHelper Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sinclair/method_definition/parameter_helper.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Helper containing helepr methods for remapping parameters

See Also:

Author:

  • darthjee

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters_list, named: nil) ⇒ ParameterHelper

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ParameterHelper.

Parameters:

  • parameters_list (Array<Object>)

    list of parameters and defaults

  • named (TrueClass, FalseClass) (defaults to: nil)

    Flag informing if the parameters are named parameters



29
30
31
32
# File 'lib/sinclair/method_definition/parameter_helper.rb', line 29

def initialize(parameters_list, named: nil)
  @parameters_list = parameters_list
  @named           = named
end

Class Method Details

.parameters_from(parameters_list, named: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a list of strings of parameters

Parameters:

  • parameters_list (Array<Object>)

    list of parameters and defaults

  • named (TrueClass, FalseClass) (defaults to: false)

    Flag informing if the parameters are named parameters

Returns:

  • (String)


20
21
22
# File 'lib/sinclair/method_definition/parameter_helper.rb', line 20

def self.parameters_from(*args, **opts)
  new(*args, **opts).strings
end

Instance Method Details

#stringsArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

All parameters converted into strings

The strings are ready to be pushed into a method definition and joined by ,

Returns:

  • (Array<String>)


40
41
42
43
44
# File 'lib/sinclair/method_definition/parameter_helper.rb', line 40

def strings
  return [] unless parameters_list

  parameters_strings + defaults_strings + wild_card_parameters
end