Module: Trxl::CaseExpression1
- Defined in:
- lib/trxl/trxl_grammar.rb
Instance Method Summary collapse
Instance Method Details
#eval(env = Environment.new) ⇒ Object
1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
# File 'lib/trxl/trxl_grammar.rb', line 1141 def eval(env = Environment.new) case_val = case_exp.eval(env) else_val = else_exp.eval(env) Kernel.eval <<-CASE case case_val #{ruby_when_expressions(env)} else #{else_val.is_a?(String) ? "'#{else_val}'" : else_val} end CASE end |
#ruby_when_expressions(env = Environment.new) ⇒ Object
1153 1154 1155 1156 1157 1158 |
# File 'lib/trxl/trxl_grammar.rb', line 1153 def ruby_when_expressions(env = Environment.new) when_expression_list.eval(env).inject('') do |ruby, e| # possible string values have been wrapped in '' already ruby << "when #{e[:condition]} then #{e[:expression]} " end end |