Class: Iba::BaseExpression

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



32
33
34
35
36
# File 'lib/iba.rb', line 32

def method_missing(method, *args)
  # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
  super if method.to_s.start_with? "_"
  MethodCallExpression.new self, method, args
end

Instance Method Details

#!=(other) ⇒ Object



53
54
55
# File 'lib/iba.rb', line 53

def !=(other)
  method_missing :!=, other
end

#==(other) ⇒ Object



49
50
51
# File 'lib/iba.rb', line 49

def ==(other)
  method_missing :==, other
end

#_display(_bnd) ⇒ Object



65
66
67
# File 'lib/iba.rb', line 65

def _display(_bnd)
  nil
end

#_display_subexpressions(_bnd) ⇒ Object



69
70
71
# File 'lib/iba.rb', line 69

def _display_subexpressions(_bnd)
  nil
end

#_wrap(arg) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/iba.rb', line 57

def _wrap(arg)
  if arg.is_a? BaseExpression
    arg
  else
    LiteralExpression.new arg
  end
end

#coerce(other) ⇒ Object

Handle numeric operator coersion



74
75
76
# File 'lib/iba.rb', line 74

def coerce(other)
  [_wrap(other), self]
end

#respond_to_missing?(method) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
# File 'lib/iba.rb', line 38

def respond_to_missing?(method)
  # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
  return super if method.to_s.start_with? "_"

  true
end

#to_sObject



45
46
47
# File 'lib/iba.rb', line 45

def to_s
  method_missing :to_s
end