### Home Classes Methods

### In Files

- lib/sass/tree/node.rb

### Parent

Object

### Methods

- ::inherited
- ::new
- #<<
- #==
- #balance
- #bubbles?
- #children=
- #css
- #css_with_sourcemap
- #deep_copy
- #each
- #filename
- #inspect
- #invisible?
- #options=
- #style
- #to_sass
- #to_scss

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- Sass
- Sass::BaseEnvironment
- Sass::CSS
- Sass::CacheStores
- Sass::CacheStores::Base
- Sass::CacheStores::Chain
- Sass::CacheStores::Filesystem
- Sass::CacheStores::Memory
- Sass::CacheStores::Null
- Sass::Callbacks
- Sass::Callbacks::InstanceMethods
- Sass::Engine
- Sass::Engine::Line
- Sass::Environment
- Sass::Exec
- Sass::Exec::Base
- Sass::Exec::SassConvert
- Sass::Exec::SassScss
- Sass::Exec::SassScss::Sass::Plugin.compiler
- Sass::Features
- Sass::Importers
- Sass::Importers::Base
- Sass::Importers::Filesystem
- Sass::Logger
- Sass::Logger::Base
- Sass::Logger::LogLevel
- Sass::Logger::LogLevel::ClassMethods
- Sass::Media
- Sass::Media::Query
- Sass::Media::QueryList
- Sass::Plugin
- Sass::Plugin::Compiler
- Sass::Plugin::Configuration
- Sass::Plugin::MerbBootLoader
- Sass::Plugin::Rack
- Sass::Plugin::StalenessChecker
- Sass::ReadOnlyEnvironment
- Sass::Repl
- Sass::SCSS
- Sass::SCSS::CssParser
- Sass::SCSS::Parser
- Sass::SCSS::RX
- Sass::SCSS::ScriptLexer
- Sass::SCSS::ScriptParser
- Sass::SCSS::StaticParser
- Sass::Script
- Sass::Script::CssLexer
- Sass::Script::CssParser
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::Lexer
- Sass::Script::Parser
- Sass::Script::Tree
- Sass::Script::Tree::Funcall
- Sass::Script::Tree::Interpolation
- Sass::Script::Tree::ListLiteral
- Sass::Script::Tree::Literal
- Sass::Script::Tree::MapLiteral
- Sass::Script::Tree::Node
- Sass::Script::Tree::Operation
- Sass::Script::Tree::Selector
- Sass::Script::Tree::StringInterpolation
- Sass::Script::Tree::UnaryOperation
- Sass::Script::Tree::Variable
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::Bool
- Sass::Script::Value::Color
- Sass::Script::Value::Helpers
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Script::Value::Null
- Sass::Script::Value::Number
- Sass::Script::Value::String
- Sass::Selector
- Sass::Selector::AbstractSequence
- Sass::Selector::Attribute
- Sass::Selector::Class
- Sass::Selector::CommaSequence
- Sass::Selector::Element
- Sass::Selector::Id
- Sass::Selector::Parent
- Sass::Selector::Placeholder
- Sass::Selector::Pseudo
- Sass::Selector::Sequence
- Sass::Selector::Simple
- Sass::Selector::SimpleSequence
- Sass::Selector::Universal
- Sass::SemiGlobalEnvironment
- Sass::Shared
- Sass::Source
- Sass::Source::Map
- Sass::Source::Map::Mapping
- Sass::Source::Position
- Sass::Source::Range
- Sass::Stack
- Sass::Stack::Frame
- Sass::Supports
- Sass::Supports::Condition
- Sass::Supports::Declaration
- Sass::Supports::Interpolation
- Sass::Supports::Negation
- Sass::Supports::Operator
- Sass::SyntaxError
- Sass::Tree
- Sass::Tree::AtRootNode
- Sass::Tree::CharsetNode
- Sass::Tree::CommentNode
- Sass::Tree::ContentNode
- Sass::Tree::CssImportNode
- Sass::Tree::DebugNode
- Sass::Tree::DirectiveNode
- Sass::Tree::EachNode
- Sass::Tree::ErrorNode
- Sass::Tree::ExtendNode
- Sass::Tree::ForNode
- Sass::Tree::FunctionNode
- Sass::Tree::IfNode
- Sass::Tree::ImportNode
- Sass::Tree::KeyframeRuleNode
- Sass::Tree::MediaNode
- Sass::Tree::MixinDefNode
- Sass::Tree::MixinNode
- Sass::Tree::Node
- Sass::Tree::PropNode
- Sass::Tree::ReturnNode
- Sass::Tree::RootNode
- Sass::Tree::RuleNode
- Sass::Tree::SupportsNode
- Sass::Tree::TraceNode
- Sass::Tree::VariableNode
- Sass::Tree::Visitors
- Sass::Tree::Visitors::Base
- Sass::Tree::Visitors::CheckNesting
- Sass::Tree::Visitors::Convert
- Sass::Tree::Visitors::Cssize
- Sass::Tree::Visitors::Cssize::Bubble
- Sass::Tree::Visitors::DeepCopy
- Sass::Tree::Visitors::Extend
- Sass::Tree::Visitors::Perform
- Sass::Tree::Visitors::SetOptions
- Sass::Tree::Visitors::ToCss
- Sass::Tree::WarnNode
- Sass::Tree::WhileNode
- Sass::UnitConversionError
- Sass::Util
- Sass::Util::CrossPlatformRandom
- Sass::Util::MultibyteStringScanner
- Sass::Util::NormalizedMap
- Sass::Util::StaticConditionalContext
- Sass::Util::SubsetMap
- Sass::Util::Test
- Sass::Version
- ActionController
- ActionController::Base
- Object
- OrderedHash

No matching classes.

# Sass::Tree::Node

The abstract superclass of all parse-tree nodes.

### Attributes

children[R]

The child nodes of this node.

@return [Array<Tree::Node>]

filename[W]

The name of the document on which this node appeared.

@return [String]

has_children[RW]

Whether or not this node has child nodes. This may be true even when {#children} is empty, in which case this node has an empty block (e.g. `{}`).

@return [Boolean]

line[RW]

The line of the document on which this node appeared.

@return [Fixnum]

options[R]

The options hash for the node. See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.

@return [{Symbol => Object}]

source_range[RW]

The source range in the document on which this node appeared.

@return [Sass::Source::Range]

### Public Class Methods

inherited(base) click to toggle source

    # File lib/sass/tree/node.rb, line 33
    def self.inherited(base)
      node_name = base.name.gsub(/.*::(.*?)Node$/, '\1').downcase
      base.instance_eval           # @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
    end

new() click to toggle source

    # File lib/sass/tree/node.rb, line 91
    def initialize
      @children = []
    end

### Public Instance Methods

<<(child) click to toggle source

Appends a child to the node.

@param child [Tree::Node, Array<Tree::Node>] The child node or nodes @raise [Sass::SyntaxError] if `child` is invalid

    # File lib/sass/tree/node.rb, line 120
    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

==(other) click to toggle source

Compares this node and another object (only other {Tree::Node}s will be equal). This does a structural comparison; if the contents of the nodes and all the child nodes are equivalent, then the nodes are as well.

Only static nodes need to override this.

@param other [Object] The object to compare with @return [Boolean] Whether or not this node and the other object

    are the same

@see Sass::Tree

    # File lib/sass/tree/node.rb, line 141
    def ==(other)
      self.class == other.class && other.children == children
    end

bubbles?() click to toggle source

Whether or not this node bubbles up through RuleNodes.

@return [Boolean]

    # File lib/sass/tree/node.rb, line 223
    def bubbles?
      false
    end

children=(children) click to toggle source

@private

    # File lib/sass/tree/node.rb, line 104
    def children=(children)
      self.has_children ||= !children.empty?
      @children = children
    end

css() click to toggle source

Computes the CSS corresponding to this static CSS tree.

@return [String] The resulting CSS @see Sass::Tree

    # File lib/sass/tree/node.rb, line 163
    def css
      Sass::Tree::Visitors::ToCss.new.visit(self)
    end

css_with_sourcemap() click to toggle source

Computes the CSS corresponding to this static CSS tree, along with the respective source map.

@return [(String, Sass::Source::Map)] The resulting CSS and the source map @see Sass::Tree

    # File lib/sass/tree/node.rb, line 172
    def css_with_sourcemap
      visitor = Sass::Tree::Visitors::ToCss.new(:build_source_mapping)
      result = visitor.visit(self)
      return result, visitor.source_mapping
    end

deep_copy() click to toggle source

Return a deep clone of this node. The child nodes are cloned, but options are not.

@return [Node]

    # File lib/sass/tree/node.rb, line 216
    def deep_copy
      Sass::Tree::Visitors::DeepCopy.visit(self)
    end

each() click to toggle source

Iterates through each node in the tree rooted at this node in a pre-order walk.

@yield node @yieldparam node [Node] a node in the tree

    # File lib/sass/tree/node.rb, line 191
    def each
      yield self
      children.each {|c| c.each {|n| yield n}}
    end

filename() click to toggle source

The name of the document on which this node appeared.

@return [String]

    # File lib/sass/tree/node.rb, line 112
    def filename
      @filename || (@options && @options[:filename])
    end

inspect() click to toggle source

Returns a representation of the node for debugging purposes.

@return [String]

    # File lib/sass/tree/node.rb, line 181
    def inspect
      return self.class.to_s unless has_children
      "(#{self.class} #{children.map {|c| c.inspect}.join(' ')})"
    end

invisible?() click to toggle source

True if {#to_s} will return `nil`; that is, if the node shouldn’t be rendered. Should only be called in a static tree.

@return [Boolean]

    # File lib/sass/tree/node.rb, line 150
    def invisible?; false; end

options=(options) click to toggle source

Sets the options hash for the node and all its children.

@param options [{Symbol => Object}] The options @see options

    # File lib/sass/tree/node.rb, line 99
    def options=(options)
      Sass::Tree::Visitors::SetOptions.visit(self, options)
    end

style() click to toggle source

The output style. See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.

@return [Symbol]

    # File lib/sass/tree/node.rb, line 155
    def style
      @options[:style]
    end

to_sass(options = {}) click to toggle source

Converts a node to Sass code that will generate it.

@param options [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @return [String] The Sass code corresponding to the node

    # File lib/sass/tree/node.rb, line 200
    def to_sass(options = {})
      Sass::Tree::Visitors::Convert.visit(self, options, :sass)
    end

to_scss(options = {}) click to toggle source

Converts a node to SCSS code that will generate it.

@param options [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}) @return [String] The Sass code corresponding to the node

    # File lib/sass/tree/node.rb, line 208
    def to_scss(options = {})
      Sass::Tree::Visitors::Convert.visit(self, options, :scss)
    end

### Protected Instance Methods

balance(*args) click to toggle source

@see Sass::Shared.balance @raise [Sass::SyntaxError] if the brackets aren’t balanced

    # File lib/sass/tree/node.rb, line 231
    def balance(*args)
      res = Sass::Shared.balance(*args)
      return res if res
      raise Sass::SyntaxError.new("Unbalanced brackets.", :line => line)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.