Class: MathExpr
- Inherits:
-
Object
- Object
- MathExpr
- Defined in:
- lib/code_generator.rb
Instance Method Summary collapse
- #gen ⇒ Object
-
#initialize(op, e1, e2) ⇒ MathExpr
constructor
A new instance of MathExpr.
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
#gen ⇒ Object
224 225 226 |
# File 'lib/code_generator.rb', line 224 def gen "#{@e1.gen} #{@operation} #{@e2.gen}" end |