Class: Sass::Script::Node
- Inherits:
-
Object
- Object
- Sass::Script::Node
- Defined in:
- /var/www/sass-pages/.haml/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
- - (Symbol) context The context in which this node was parsed, which determines how some operations are performed.
- - (Fixnum) line The line of the document on which this node appeared.
- - ({Symbol => Object}) options The options hash for this node.
Instance Method Summary
- - (Literal) _perform(environment) protected Evaluates this node.
- - (Array<Node>) children Returns all child nodes of this node.
- - dasherize(s, opts) protected Converts underscores to dashes if the :dasherize option is set.
- - (Node) initialize constructor Creates a new script node.
- - (Literal) perform(environment) Evaluates the node.
- - (String) to_sass(opts = {}) Returns the text of this SassScript expression.
Constructor Details
- (Node) initialize
Creates a new script node.
49 50 51 |
# File '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 49
def initialize
@context = :default
end
|
Instance Attribute Details
- (Symbol) context
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 '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 21
def context
@context
end
|
- (Fixnum) line
The line of the document on which this node appeared.
26 27 28 |
# File '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 26
def line
@line
end
|
- ({Symbol => Object}) options
The options hash for this node.
9 10 11 |
# File '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 9
def options
@options
end
|
Instance Method Details
- (Literal) _perform(environment) (protected)
Evaluates this node.
97 98 99 |
# File '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 97
def _perform(environment)
raise NotImplementedError.new("All subclasses of Sass::Script::Node must override #_perform.")
end
|
- (Array<Node>) children
Returns all child nodes of this node.
70 71 72 |
# File '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 70
def children
raise NotImplementedError.new("All subclasses of Sass::Script::Node must override #children.")
end
|
- dasherize(s, opts) (protected)
Converts underscores to dashes if the :dasherize option is set.
84 85 86 87 88 89 90 |
# File '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 84
def dasherize(s, opts)
if opts[:dasherize]
s.gsub(/_/,'-')
else
s
end
end
|
- (Literal) perform(environment)
60 61 62 63 64 65 |
# File '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 60
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.
77 78 79 |
# File '/var/www/sass-pages/.haml/lib/sass/script/node.rb', line 77
def to_sass(opts = {})
raise NotImplementedError.new("All subclasses of Sass::Script::Node must override #to_sass.")
end
|