Class: Babl::Nodes::Switch

Inherits:
Object
  • Object
show all
Defined in:
lib/babl/nodes/switch.rb

Instance Method Summary collapse

Constructor Details

#initialize(nodes) ⇒ Switch

Returns a new instance of Switch.



11
12
13
14
15
# File 'lib/babl/nodes/switch.rb', line 11

def initialize(nodes)
    raise Errors::InvalidTemplate, 'A least one switch() condition must be taken' if nodes.empty?

    super
end

Instance Method Details

#render(frame) ⇒ Object



39
40
41
42
# File 'lib/babl/nodes/switch.rb', line 39

def render(frame)
    nodes.each { |cond, value| return value.render(frame) if cond.render(frame) }
    raise Errors::RenderingError, 'A least one switch() condition must be taken'
end