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)

Raises:
  • (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)

Other tags:
    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)

Raises:
  • (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?

Returns:
  • (Boolean) -
def bubbles?
  false
end

def children=(children)

Other tags:
    Private: -
def children=(children)
  self.has_children ||= !children.empty?
  @children = children
end

def css

Other tags:
    See: Sass::Tree -

Returns:
  • (String) - The resulting CSS
def css
  Sass::Tree::Visitors::ToCss.new.visit(self)
end

def css_with_sourcemap

Other tags:
    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

Returns:
  • (Node) -
def deep_copy
  Sass::Tree::Visitors::DeepCopy.visit(self)
end

def each

Other tags:
    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

Returns:
  • (String) -
def filename
  @filename || (@options && @options[:filename])
end

def initialize

def initialize
  @children = []
  @filename = nil
  @options = nil
end

def inspect

Returns:
  • (String) -
def inspect
  return self.class.to_s unless has_children
  "(#{self.class} #{children.map {|c| c.inspect}.join(' ')})"
end

def invisible?; false; end

Returns:
  • (Boolean) -
def invisible?; false; end

def options=(options)

Other tags:
    See: #options -

Parameters:
  • options ({Symbol => Object}) -- The options
def options=(options)
  Sass::Tree::Visitors::SetOptions.visit(self, options)
end

def style

Returns:
  • (Symbol) -
def style
  @options[:style]
end

def to_sass(options = {})

Returns:
  • (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 = {})

Returns:
  • (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