Class: Sass::Tree::IfNode
Overview
Instance Attribute Summary collapse
-
#else ⇒ IfNode
The next IfNode in the if-else list, or
nil
.
Attributes inherited from Node
#children, #filename, #line, #options
Instance Method Summary collapse
-
#_perform(environment) ⇒ Array<Tree::Node>
protected
Runs the child nodes if the conditional expression is true; otherwise, tries the #else nodes.
-
#add_else(node) ⇒ Object
Append an
@else
node to the end of the list. -
#initialize(expr) ⇒ IfNode
constructor
A new instance of IfNode.
- #options=(options) ⇒ Object
Methods inherited from Node
#<<, #==, #_to_s, #balance, #interpolate, #invalid_child?, #invisible?, #last, #perform, #perform!, #perform_children, #render, #style, #to_s, #to_sass
Constructor Details
#initialize(expr) ⇒ IfNode
Returns a new instance of IfNode.
19 20 21 22 23 |
# File 'lib/sass/tree/if_node.rb', line 19
def initialize(expr)
@expr = expr
@last_else = self
super()
end
|
Instance Attribute Details
#else ⇒ IfNode
The next Sass::Tree::IfNode in the if-else list, or nil
.
15 16 17 |
# File 'lib/sass/tree/if_node.rb', line 15
def else
@else
end
|
Instance Method Details
#_perform(environment) ⇒ Array<Tree::Node> (protected)
Runs the child nodes if the conditional expression is true; otherwise, tries the #else nodes.
47 48 49 50 51 52 |
# File 'lib/sass/tree/if_node.rb', line 47
def _perform(environment)
environment = Sass::Environment.new(environment)
return perform_children(environment) if @expr.nil? || @expr.perform(environment).to_bool
return @else.perform(environment) if @else
[]
end
|
#add_else(node) ⇒ Object
Append an @else
node to the end of the list.
28 29 30 31 |
# File 'lib/sass/tree/if_node.rb', line 28
def add_else(node)
@last_else.else = node
@last_else = node
end
|
#options=(options) ⇒ Object
33 34 35 36 |
# File 'lib/sass/tree/if_node.rb', line 33
def options=(options)
super
self.else.options = options if self.else
end
|