Class: Iba::EmptyExpression

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

Instance Method Summary collapse

Methods inherited from BaseExpression

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

Dynamic Method Handling

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

Instance Method Details

#_override_instance_variables(vars) ⇒ Object



98
99
100
101
102
103
104
105
# File 'lib/iba.rb', line 98

def _override_instance_variables(vars)
  vars.each do |v|
    # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
    next if v.to_s.start_with? "@_"

    instance_variable_set v, Iba::InstanceVariableExpression.new(v.to_sym)
  end
end

#_override_local_variables(vars, bnd) ⇒ Object



107
108
109
110
111
112
113
114
115
# File 'lib/iba.rb', line 107

def _override_local_variables(vars, bnd)
  vars.each do |v|
    # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
    next if v.to_s.start_with? "_"

    bnd.local_variable_set "_#{v}", bnd.local_variable_get(v)
    bnd.local_variable_set v, LocalVariableExpression.new(v.to_sym)
  end
end

#_parse(&blk) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/iba.rb', line 80

def _parse(&blk)
  bnd = blk.binding

  vars = bnd.local_variables
  ivars = bnd.receiver.instance_variables

  _override_instance_variables ivars

  _override_local_variables vars, bnd

  result = instance_eval(&blk)
  result = _wrap(result)

  _restore_local_variables vars, bnd

  result
end

#_restore_local_variables(vars, bnd) ⇒ Object



117
118
119
120
121
122
123
124
# File 'lib/iba.rb', line 117

def _restore_local_variables(vars, bnd)
  vars.each do |v|
    # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
    next if v.to_s.start_with? "_"

    bnd.local_variable_set v, bnd.local_variable_get("_#{v}")
  end
end

#_to_sObject



126
127
128
# File 'lib/iba.rb', line 126

def _to_s
  ""
end