Class: Sass::Script::Node

Inherits:
Object
  • Object
show all
Defined in:
/var/www/sass-pages/.sass/lib/sass/script/node.rb

Overview

The abstract superclass for SassScript parse tree nodes.

Use #perform to evaluate a parse tree.

Direct Known Subclasses

Funcall, Interpolation, Literal, Operation, StringInterpolation, UnaryOperation, Variable

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

- (Fixnum) line

The line of the document on which this node appeared.

Returns:

  • (Fixnum)


14
15
16
# File '/var/www/sass-pages/.sass/lib/sass/script/node.rb', line 14

def line
  @line
end

- ({Symbol => Object}) options

The options hash for this node.

Returns:

  • ({Symbol => Object})


9
10
11
# File '/var/www/sass-pages/.sass/lib/sass/script/node.rb', line 9

def options
  @options
end

Instance Method Details

- (Literal) _perform(environment) (protected)

Evaluates this node. Note that all Literal objects created within this method should have their #options attribute set, probably via #opts.

Parameters:

  • (Sass::Environment) 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 '/var/www/sass-pages/.sass/lib/sass/script/node.rb', line 86

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

- (Array<Node>) children

Returns all child nodes of this node.

Returns:



49
50
51
# File '/var/www/sass-pages/.sass/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 '/var/www/sass-pages/.sass/lib/sass/script/node.rb', line 71

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

- (Node) deep_copy

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

Returns:



64
65
66
# File '/var/www/sass-pages/.sass/lib/sass/script/node.rb', line 64

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

- (Literal) opts(literal) (protected)

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

Parameters:

Returns:



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

def opts(literal)
  literal.options = options
  literal
end

- (Literal) perform(environment)

Evaluates the node.

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

Parameters:

  • (Sass::Environment) 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 '/var/www/sass-pages/.sass/lib/sass/script/node.rb', line 39

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

- (String) to_sass(opts = {})

Returns the text of this SassScript expression.

Returns:



56
57
58
# File '/var/www/sass-pages/.sass/lib/sass/script/node.rb', line 56

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