Class: Sass::Script::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/sass/script/node.rb

Overview

The abstract superclass for SassScript parse tree nodes.

Use #perform to evaluate a parse tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Creates a new script node.



49
50
51
# File 'lib/sass/script/node.rb', line 49

def initialize
  @context = :default
end

Instance Attribute Details

#contextSymbol

The context in which this node was parsed, which determines how some operations are performed.

Can be :equals, which means it's part of a $var = val or prop = val assignment, or :default, which means it's anywhere else (including $var: val and prop: val assignments, #{}-interpolations, and other script contexts such as @if conditions).

Returns:

  • (Symbol)


21
22
23
# File 'lib/sass/script/node.rb', line 21

def context
  @context
end

#lineFixnum

The line of the document on which this node appeared.

Returns:

  • (Fixnum)


26
27
28
# File 'lib/sass/script/node.rb', line 26

def line
  @line
end

#options{Symbol => Object}

The options hash for this node.

Returns:

  • ({Symbol => Object})


9
10
11
# File 'lib/sass/script/node.rb', line 9

def options
  @options
end

Instance Method Details

#_perform(environment) ⇒ Literal (protected)

Evaluates this node.

Parameters:

  • environment (Sass::Environment)

    The environment in which to evaluate the SassScript

Returns:

  • (Literal)

    The SassScript object that is the value of the SassScript

See Also:



97
98
99
# File 'lib/sass/script/node.rb', line 97

def _perform(environment)
  Haml::Util.abstract(self)
end

#childrenArray<Node>

Returns all child nodes of this node.

Returns:



70
71
72
# File 'lib/sass/script/node.rb', line 70

def children
  Haml::Util.abstract(self)
end

#dasherize(s, opts) (protected)

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



84
85
86
87
88
89
90
# File 'lib/sass/script/node.rb', line 84

def dasherize(s, opts)
  if opts[:dasherize]
    s.gsub(/_/,'-')
  else
    s
  end
end

#perform(environment) ⇒ Literal

Evaluates the node.

#perform shouldn't be overridden directly; instead, override #_perform.

Parameters:

  • environment (Sass::Environment)

    The environment in which to evaluate the SassScript

Returns:

  • (Literal)

    The SassScript object that is the value of the SassScript



60
61
62
63
64
65
# File 'lib/sass/script/node.rb', line 60

def perform(environment)
  _perform(environment)
rescue Sass::SyntaxError => e
  e.modify_backtrace(:line => line)
  raise e
end

#to_sass(opts = {}) ⇒ String

Returns the text of this SassScript expression.

Returns:



77
78
79
# File 'lib/sass/script/node.rb', line 77

def to_sass(opts = {})
  Haml::Util.abstract(self)
end