Class: Sinclair::MethodDefinition::ParameterBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sinclair/method_definition/parameter_builder.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.

Builder a string of parameters

This is used when creating the string for a method defined using a string definition

See Also:

Author:

  • darthjee

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters, named_parameters) ⇒ ParameterBuilder

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 ParameterBuilder.

Parameters:

  • parameters (Array<Object>)

    List of parameters.

  • named_parameters (Array<Object>)

    List of named parameters



34
35
36
37
# File 'lib/sinclair/method_definition/parameter_builder.rb', line 34

def initialize(parameters, named_parameters)
  @parameters       = parameters
  @named_parameters = named_parameters
end

Class Method Details

.from(parameters, named_parameters) ⇒ 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.

Builds a string representing method parameters

The list of parameters/named_parameters is formed by an array of Symbol representing required parameters and Hash representing parameters with default values

Parameters:

  • parameters (Array<Object>)

    List of parameters.

  • named_parameters (Array<Object>)

    List of named parameters

Returns:

  • (String)


26
27
28
# File 'lib/sinclair/method_definition/parameter_builder.rb', line 26

def self.from(*args)
  new(*args).to_s
end

Instance Method Details

#to_sString

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 the parameters string

Returns:

  • (String)


42
43
44
45
46
# File 'lib/sinclair/method_definition/parameter_builder.rb', line 42

def to_s
  return '' if empty_parameters?

  "(#{parameters_string})"
end