Sha256: d4893537e28077974ed59451a42cbed4b0fd08a5f610fb5bc976b06867377ab7

Contents?: true

Size: 385 Bytes

Versions: 1

Compression:

Stored size: 385 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'treetop'
require_relative 'boolean_expr'

# A boolean expression with two children and an operator
class BinaryExpr < BooleanExpr
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emerald-lang-1.0.0 lib/emerald/nodes/binary_expr.rb