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.



207
208
209
210
# File 'lib/code_generator.rb', line 207

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

Instance Method Details

#genObject



212
213
214
# File 'lib/code_generator.rb', line 212

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