Class: MathExpr

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

Instance Method Summary collapse

Constructor Details

#initialize(op, e1, e2) ⇒ MathExpr

Returns a new instance of MathExpr.



219
220
221
222
# File 'lib/code_generator.rb', line 219

def initialize op, e1, e2
  @e1, @e2 = e1, e2
  @operation = { plus: '+', minus: '-' }[op]
end

Instance Method Details

#genObject



224
225
226
# File 'lib/code_generator.rb', line 224

def gen
  "#{@e1.gen} #{@operation} #{@e2.gen}"
end