Class: Sass::Script::Tree::Node

Inherits:
Object
  • Object
show all
Defined in:
/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb

Overview

The abstract superclass for SassScript parse tree nodes.

Use #perform to evaluate a parse tree.

Direct Known Subclasses

Funcall, Interpolation, ListLiteral, Literal, MapLiteral, Operation, Selector, StringInterpolation, UnaryOperation, Variable

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (String) filename

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

Returns:

  • (String)


24
25
26
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 24

def filename
  @filename
end

- (Integer) line

The line of the document on which this node appeared.

Returns:

  • (Integer)


14
15
16
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 14

def line
  @line
end

- ({Symbol => Object}) options

The options hash for this node.

Returns:

  • ({Symbol => Object})


9
10
11
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 9

def options
  @options
end

- (Sass::Source::Range) source_range

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

Returns:



19
20
21
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 19

def source_range
  @source_range
end

Instance Method Details

- (Sass::Script::Value) _perform(environment) (protected)

Evaluates this node. Note that all Value 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:

See Also:



106
107
108
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 106

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

- (Array<Node>) children

Returns all child nodes of this node.

Returns:



59
60
61
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 59

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

- dasherize(s, opts) (protected)

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



91
92
93
94
95
96
97
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 91

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

- (Node) deep_copy

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

Returns:



78
79
80
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 78

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

- force_division!

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



84
85
86
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 84

def force_division!
  children.each {|c| c.force_division!}
end

- (Sass::Script::Value) opts(value) (protected)

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

Parameters:

Returns:



114
115
116
117
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 114

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

- (Sass::Script::Value) perform(environment)

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:



49
50
51
52
53
54
# File '/home/nweiz/code/sass-site/.sass/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

- (String) to_sass(opts = {})

Returns the text of this SassScript expression.

Returns:

  • (String)


70
71
72
# File '/home/nweiz/code/sass-site/.sass/lib/sass/script/tree/node.rb', line 70

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