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

Instance Attribute Details

#lineFixnum

The line of the document on which this node appeared.

Returns:

  • (Fixnum)


14
15
16
# File 'lib/sass/script/node.rb', line 14

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. Note that all Literal objects created within this method should have their #options attribute set, probably via #opts.

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:



86
87
88
# File 'lib/sass/script/node.rb', line 86

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

#childrenArray<Node>

Returns all child nodes of this node.

Returns:



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

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

#dasherize(s, opts) (protected)

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



71
72
73
74
75
76
77
# File 'lib/sass/script/node.rb', line 71

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

#deep_copyNode

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

Returns:



64
65
66
# File 'lib/sass/script/node.rb', line 64

def deep_copy
  Sass::Util.abstract(self)
end

#opts(literal) ⇒ Literal (protected)

Sets the #options field on the given literal and returns it

Parameters:

Returns:



94
95
96
97
# File 'lib/sass/script/node.rb', line 94

def opts(literal)
  literal.options = options
  literal
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



39
40
41
42
43
44
# File 'lib/sass/script/node.rb', line 39

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:



56
57
58
# File 'lib/sass/script/node.rb', line 56

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