Class: BinaryExpr

Inherits:
BooleanExpr
  • Object
show all
Defined in:
lib/emerald/nodes/binary_expr.rb

Overview

A boolean expression with two children and an operator

Instance Method Summary collapse

Instance Method Details

#truthy?(context) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
# File 'lib/emerald/nodes/binary_expr.rb', line 9

def truthy?(context)
  case op.text_value
  when 'and'
    lhs.truthy?(context) && rhs.truthy?(context)
  when 'or'
    lhs.truthy?(context) || rhs.truthy?(context)
  end
end