Class: Renshi::AttributeExpressions::Elsif

Inherits:
Object
  • Object
show all
Defined in:
lib/renshi/attribute_expressions/elsif.rb

Instance Method Summary collapse

Instance Method Details

#evaluate(expression, node) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/renshi/attribute_expressions/elsif.rb', line 4

def evaluate(expression, node)
  node.open_clause("elsif (#{expression})")
  
  sibling = node.next_real
  
  if sibling
    sibling_commands = sibling.commands
  
    if sibling_commands.first
      expression = sibling_commands.first[0][2..-1]
      if expression == "else" or expression == "elsif"
        return
      end
    end
  end
  
  node.close_clause("end")
end