Class: Babl::Nodes::Switch
- Inherits:
-
Object
- Object
- Babl::Nodes::Switch
- Defined in:
- lib/babl/nodes/switch.rb
Instance Method Summary collapse
-
#initialize(nodes) ⇒ Switch
constructor
A new instance of Switch.
- #render(frame) ⇒ Object
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 |