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.
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
#gen ⇒ Object
212 213 214 |
# File 'lib/code_generator.rb', line 212 def gen "#{@e1.gen} #{@operation} #{@e2.gen}" end |