class Sass::Script::Tree::Node

The abstract superclass for SassScript parse tree nodes.

Use {#perform} to evaluate a parse tree.

Attributes

filename[RW]

The file name of the document on which this node appeared.

@return [String]

line[RW]

The line of the document on which this node appeared.

@return [Integer]

options[R]

The options hash for this node.

@return [{Symbol => Object}]

source_range[RW]

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

@return [Sass::Source::Range]

Public Instance Methods

children() click to toggle source

Returns all child nodes of this node.

@return [Array<Node>]

# File lib/sass/script/tree/node.rb, line 59
def children
  Sass::Util.abstract(self)
end
deep_copy() click to toggle source

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

@return [Node]

# File lib/sass/script/tree/node.rb, line 78
def deep_copy
  Sass::Util.abstract(self)
end
force_division!() click to toggle source

Forces any division operations with number literals in this expression to do real division, rather than returning strings.

# File lib/sass/script/tree/node.rb, line 84
def force_division!
  children.each {|c| c.force_division!}
end
options=(options) click to toggle source

Sets the options hash for this node, as well as for all child nodes. See {file:SASS_REFERENCE.md#Options the Sass options documentation}.

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

# File lib/sass/script/tree/node.rb, line 31
def options=(options)
  @options = options
  children.each do |c|
    if c.is_a? Hash
      c.values.each {|v| v.options = options}
    else
      c.options = options
    end
  end
end
perform(environment) click to toggle source

Evaluates the node.

{#perform} shouldn’t be overridden directly; instead, override {#_perform}.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Sass::Script::Value] The SassScript object that is the value of the SassScript

# File lib/sass/script/tree/node.rb, line 49
def perform(environment)
  _perform(environment)
rescue Sass::SyntaxError => e
  e.modify_backtrace(:line => line)
  raise e
end
to_sass(opts = {}) click to toggle source

Returns the text of this SassScript expression.

@options opts :quote [String]

The preferred quote style for quoted strings. If `:none`, strings are
always emitted unquoted.

@return [String]

# File lib/sass/script/tree/node.rb, line 70
def to_sass(opts = {})
  Sass::Util.abstract(self)
end

Protected Instance Methods

_perform(environment) click to toggle source

Evaluates this node. Note that all {Sass::Script::Value} objects created within this method should have their {#options} attribute set, probably via {#opts}.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Sass::Script::Value] The SassScript object that is the value of the SassScript @see perform

# File lib/sass/script/tree/node.rb, line 106
def _perform(environment)
  Sass::Util.abstract(self)
end
dasherize(s, opts) click to toggle source

Converts underscores to dashes if the :dasherize option is set.

# File lib/sass/script/tree/node.rb, line 91
def dasherize(s, opts)
  if opts[:dasherize]
    s.tr('_', '-')
  else
    s
  end
end
opts(value) click to toggle source

Sets the {#options} field on the given value and returns it.

@param value [Sass::Script::Value] @return [Sass::Script::Value]

# File lib/sass/script/tree/node.rb, line 114
def opts(value)
  value.options = options
  value
end