Class: Lucio::Operator::Conditional

Inherits:
Macro
  • Object
show all
Defined in:
lib/lucio/operators/conditional.rb

Instance Attribute Summary

Attributes inherited from Macro

#type

Instance Method Summary collapse

Methods inherited from Macro

#initialize

Constructor Details

This class inherits a constructor from Lucio::Operator::Macro

Instance Method Details

#execute(lexicon, list) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/lucio/operators/conditional.rb', line 6

def execute(lexicon, list)
  tree = list.tree
  condition = Lucio::Runner.run List.new(tree[0]), lexicon

  if condition
    Lucio::Runner.run List.new(tree[1]), lexicon
  else
    Lucio::Runner.run(List.new(tree[2]), lexicon) if tree.size > 2
  end
end