Class: ComparisonExpr

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

Instance Method Summary collapse

Constructor Details

#initialize(comparison, e1, e2) ⇒ ComparisonExpr

Returns a new instance of ComparisonExpr.



191
192
193
194
195
196
197
198
199
200
201
# File 'lib/code_generator.rb', line 191

def initialize comparison, e1, e2
  @e1, @e2 = e1, e2
  @comparison = {
    gteq: '>=',
    lteq: '<=',
    neq: '!=',
    eq: '==',
    gt: '>',
    lt: '<',
  }[comparison]
end

Instance Method Details

#genObject



203
204
205
# File 'lib/code_generator.rb', line 203

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