Class: Sass::Script::Node
- Inherits:
-
Object
- Object
- Sass::Script::Node
- Defined in:
- 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 collapse
-
#context ⇒ Symbol
The context in which this node was parsed, which determines how some operations are performed.
-
#line ⇒ Fixnum
The line of the document on which this node appeared.
-
#options ⇒ {Symbol => Object}
The options hash for this node.
Instance Method Summary collapse
-
#_perform(environment) ⇒ Literal
protected
Evaluates this node.
-
#children ⇒ Array<Node>
Returns all child nodes of this node.
-
#dasherize(s, opts)
protected
Converts underscores to dashes if the :dasherize option is set.
-
#initialize ⇒ Node
constructor
Creates a new script node.
-
#perform(environment) ⇒ Literal
Evaluates the node.
-
#to_sass(opts = {}) ⇒ String
Returns the text of this SassScript expression.
Constructor Details
#initialize ⇒ Node
Creates a new script node.
49 50 51 |
# File 'lib/sass/script/node.rb', line 49
def initialize
@context = :default
end
|
Instance Attribute Details
#context ⇒ Symbol
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).
21 22 23 |
# File 'lib/sass/script/node.rb', line 21
def context
@context
end
|
#line ⇒ Fixnum
The line of the document on which this node appeared.
26 27 28 |
# File 'lib/sass/script/node.rb', line 26
def line
@line
end
|
#options ⇒ {Symbol => Object}
The options hash for this node.
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.
97 98 99 |
# File 'lib/sass/script/node.rb', line 97
def _perform(environment)
Haml::Util.abstract(self)
end
|
#children ⇒ Array<Node>
Returns all child nodes of this node.
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
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.
77 78 79 |
# File 'lib/sass/script/node.rb', line 77
def to_sass(opts = {})
Haml::Util.abstract(self)
end
|