class Sass::Tree::Node
The abstract superclass of all parse-tree nodes.
def self.inherited(base)
def self.inherited(base) node_name = base.name.gsub(/.*::(.*?)Node$/, '\\1').downcase base.instance_eval <<-METHODS # @return [Symbol] The name that is used for this node when visiting. def node_name :#{node_name} end # @return [Symbol] The method that is used on the visitor to visit nodes of this type. def visit_method :visit_#{node_name} end # @return [Symbol] The method name that determines if the parent is invalid. def invalid_child_method_name :"invalid_#{node_name}_child?" end # @return [Symbol] The method name that determines if the node is an invalid parent. def invalid_parent_method_name :"invalid_#{node_name}_parent?" end METHODS end
def <<(child)
-
(Sass::SyntaxError)
- if `child` is invalid
Parameters:
-
child
(Tree::Node, Array
) -- The child node or nodes
def <<(child) return if child.nil? if child.is_a?(Array) child.each {|c| self << c} else self.has_children = true @children << child end end
def ==(other)
- See: Sass::Tree -
Returns:
-
(Boolean)
- Whether or not this node and the other object
Parameters:
-
other
(Object
) -- The object to compare with
def ==(other) self.class == other.class && other.children == children end
def balance(*args)
-
(Sass::SyntaxError)
- if the brackets aren't balanced
Other tags:
- See: Sass::Shared.balance -
def balance(*args) res = Sass::Shared.balance(*args) return res if res raise Sass::SyntaxError.new("Unbalanced brackets.", :line => line) end
def bubbles?
-
(Boolean)
-
def bubbles? false end
def children=(children)
- Private: -
def children=(children) self.has_children ||= !children.empty? @children = children end
def css
- See: Sass::Tree -
Returns:
-
(String)
- The resulting CSS
def css Sass::Tree::Visitors::ToCss.new.visit(self) end
def css_with_sourcemap
- See: Sass::Tree -
Returns:
-
((String, Sass::Source::Map))
- The resulting CSS and the source map
def css_with_sourcemap visitor = Sass::Tree::Visitors::ToCss.new(:build_source_mapping) result = visitor.visit(self) return result, visitor.source_mapping end
def deep_copy
-
(Node)
-
def deep_copy Sass::Tree::Visitors::DeepCopy.visit(self) end
def each
- Yieldparam: node - a node in the tree
Other tags:
- Yield: - node
def each yield self children.each {|c| c.each {|n| yield n}} end
def filename
-
(String)
-
def filename @filename || (@options && @options[:filename]) end
def initialize
def initialize @children = [] @filename = nil @options = nil end
def inspect
-
(String)
-
def inspect return self.class.to_s unless has_children "(#{self.class} #{children.map {|c| c.inspect}.join(' ')})" end
def invisible?; false; end
-
(Boolean)
-
def invisible?; false; end
def options=(options)
- See: #options -
Parameters:
-
options
({Symbol => Object}
) -- The options
def options=(options) Sass::Tree::Visitors::SetOptions.visit(self, options) end
def style
-
(Symbol)
-
def style @options[:style] end
def to_sass(options = {})
-
(String)
- The Sass code corresponding to the node
Parameters:
-
options
({Symbol => Object}
) -- An options hash (see {Sass::CSS#initialize})
def to_sass(options = {}) Sass::Tree::Visitors::Convert.visit(self, options, :sass) end
def to_scss(options = {})
-
(String)
- The Sass code corresponding to the node
Parameters:
-
options
({Symbol => Object}
) -- An options hash (see {Sass::CSS#initialize})
def to_scss(options = {}) Sass::Tree::Visitors::Convert.visit(self, options, :scss) end