Class: ParameterSubstitution::MethodCallExpression
- Inherits:
-
Object
- Object
- ParameterSubstitution::MethodCallExpression
- Defined in:
- lib/parameter_substitution/method_call_expression.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call_method(value) ⇒ Object
- #encoding ⇒ Object
-
#initialize(name, arguments) ⇒ MethodCallExpression
constructor
A new instance of MethodCallExpression.
- #validate ⇒ Object
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
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/parameter_substitution/method_call_expression.rb', line 5 def arguments @arguments end |
#name ⇒ Object (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 |
#encoding ⇒ Object
27 28 29 |
# File 'lib/parameter_substitution/method_call_expression.rb', line 27 def encoding format_class.encoding end |
#validate ⇒ Object
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 |