Class: ParameterSubstitution::MethodCallExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/parameter_substitution/method_call_expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, arguments) ⇒ MethodCallExpression

Returns a new instance of MethodCallExpression.



7
8
9
10
# File 'lib/parameter_substitution/method_call_expression.rb', line 7

def initialize(name, arguments)
  @name = name
  @arguments = arguments || []
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



5
6
7
# File 'lib/parameter_substitution/method_call_expression.rb', line 5

def arguments
  @arguments
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/parameter_substitution/method_call_expression.rb', line 5

def name
  @name
end

Instance Method Details

#call_method(value) ⇒ Object



23
24
25
# File 'lib/parameter_substitution/method_call_expression.rb', line 23

def call_method(value)
  column_formatter.format(value)
end

#encodingObject



27
28
29
# File 'lib/parameter_substitution/method_call_expression.rb', line 27

def encoding
  format_class.encoding
end

#validateObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/parameter_substitution/method_call_expression.rb', line 12

def validate
  if format_class
    expected_arguments = format_class&.has_parameters? ? format_class.instance_method(:initialize).arity : 0
    if @arguments.size != expected_arguments
      raise ParameterSubstitution::ParseError, "Wrong number of arguments for '#{@name}' expected #{expected_arguments}, received #{@arguments.size}"
    end
  else
    raise ParameterSubstitution::ParseError, "Unknown method '#{@name}'"
  end
end