Class: Daedalus::DependencyGrapher::If

Inherits:
Node
  • Object
show all
Includes:
Conditional, Container
Defined in:
lib/daedalus/dependency_grapher.rb

Direct Known Subclasses

ElseIf

Instance Attribute Summary

Attributes included from Container

#body

Instance Method Summary collapse

Methods included from Conditional

#add_else

Methods included from Container

#close, #execute_body

Methods inherited from Node

#add_else, #close

Constructor Details

#initialize(expression, parser) ⇒ If

Returns a new instance of If.



273
274
275
276
277
# File 'lib/daedalus/dependency_grapher.rb', line 273

def initialize(expression, parser)
  super parser
  @value = nil
  @expression = expression.strip
end

Instance Method Details

#execute(defines, node) ⇒ Object



279
280
281
282
283
284
285
286
287
# File 'lib/daedalus/dependency_grapher.rb', line 279

def execute(defines, node)
  @value = ExpressionEvaluator.new(@expression).evaluate defines

  if @value
    execute_body(defines, node)
  elsif @else
    @else.execute(defines, node)
  end
end