Module: Trxl::IfExpression3

Defined in:
lib/trxl/trxl_grammar.rb

Instance Method Summary collapse

Instance Method Details

#elsif_expressions(env = Environment.new) ⇒ Object



746
747
748
# File 'lib/trxl/trxl_grammar.rb', line 746

def elsif_expressions(env = Environment.new)
  (elsif_branches && !elsif_branches.empty?) ? elsif_branches.elsif_expression_list.elsif_expressions : []
end

#eval(env = Environment.new) ⇒ Object



738
739
740
741
742
743
744
# File 'lib/trxl/trxl_grammar.rb', line 738

def eval(env = Environment.new)
  return if_branch.eval(env) if if_exp.eval(env)
  elsif_expressions.each do |e|
    return e.statement_list.eval(env) if e.elsif_exp.eval(env)
  end
  (else_branch && !else_branch.empty?) ? else_branch.statement_list.eval(env) : nil
end