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

Inherits:
Object
  • Object
show all
Defined in:
lib/sass/script/tree/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

#filenameString

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


24
25
26
# File 'lib/sass/script/tree/node.rb', line 24

def filename
  @filename
end

#lineFixnum

The line of the document on which this node appeared.


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

def line
  @line
end

#options{Symbol => Object}

The options hash for this node.


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

def options
  @options
end

#source_rangeSass::Source::Range

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


19
20
21
# File 'lib/sass/script/tree/node.rb', line 19

def source_range
  @source_range
end

Instance Method Details

#_perform(environment) ⇒ Sass::Script::Value (protected)

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

See Also:


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

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

#childrenArray<Node>

Returns all child nodes of this node.


59
60
61
# File '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.


81
82
83
84
85
86
87
# File 'lib/sass/script/tree/node.rb', line 81

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.


74
75
76
# File 'lib/sass/script/tree/node.rb', line 74

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

#opts(value) ⇒ Sass::Script::Value (protected)

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


104
105
106
107
# File 'lib/sass/script/tree/node.rb', line 104

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

#perform(environment) ⇒ Sass::Script::Value

Evaluates the node.

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


49
50
51
52
53
54
# 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 = {}) ⇒ String

Returns the text of this SassScript expression.


66
67
68
# File 'lib/sass/script/tree/node.rb', line 66

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