Class: Iba::MethodCallExpression

Inherits:
DisplayableExpression show all
Defined in:
lib/iba.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DisplayableExpression

#_display

Methods inherited from BaseExpression

#!=, #==, #_display, #_wrap, #coerce, #method_missing, #respond_to_missing?, #to_s

Constructor Details

#initialize(reciever, methodname, args) ⇒ MethodCallExpression

Returns a new instance of MethodCallExpression.



187
188
189
190
191
192
# File 'lib/iba.rb', line 187

def initialize(reciever, methodname, args)
  super()
  @_reciever = reciever
  @_method = methodname
  @_args = args.map { |a| _wrap(a) }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Iba::BaseExpression

Instance Attribute Details

#_argsObject (readonly)

Returns the value of attribute _args.



185
186
187
# File 'lib/iba.rb', line 185

def _args
  @_args
end

#_methodObject (readonly)

Returns the value of attribute _method.



185
186
187
# File 'lib/iba.rb', line 185

def _method
  @_method
end

#_recieverObject (readonly)

Returns the value of attribute _reciever.



185
186
187
# File 'lib/iba.rb', line 185

def _reciever
  @_reciever
end

Instance Method Details

#_display_subexpressions(bnd) ⇒ Object



210
211
212
213
214
# File 'lib/iba.rb', line 210

def _display_subexpressions(bnd)
  rcv = @_reciever._display(bnd)
  args = @_args.map { |arg| arg._display(bnd) }
  [rcv, *args].compact.join(", ")
end

#_evaluate(bnd) ⇒ Object



204
205
206
207
208
# File 'lib/iba.rb', line 204

def _evaluate(bnd)
  rcv = @_reciever._evaluate(bnd)
  args = @_args.map { |arg| arg._evaluate(bnd) }
  rcv.send @_method, *args
end

#_to_sObject



194
195
196
197
198
199
200
201
202
# File 'lib/iba.rb', line 194

def _to_s
  if @_method == :[]
    _index_to_s
  elsif _method_is_operator?
    _operator_to_s
  else
    _regular_method_to_s
  end
end