Class: Sass::Tree::Node
- Defined in:
- lib/sass/css.rb,
lib/sass/tree/node.rb
Direct Known Subclasses
AttrNode, CommentNode, DebugNode, DirectiveNode, FileNode, ForNode, IfNode, MixinDefNode, MixinNode, RuleNode, VariableNode, WhileNode
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#line ⇒ Object
Returns the value of attribute line.
Instance Method Summary collapse
- #<<(child) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(options) ⇒ Node
constructor
A new instance of Node.
-
#last ⇒ Object
We need this because Node duck types as an Array in engine.rb.
- #perform(environment) ⇒ Object
- #to_s ⇒ Object
- #to_sass(opts = {}) ⇒ Object
Constructor Details
#initialize(options) ⇒ Node
Returns a new instance of Node.
8 9 10 11 12 |
# File 'lib/sass/tree/node.rb', line 8 def initialize() @options = @style = [:style] @children = [] end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
4 5 6 |
# File 'lib/sass/tree/node.rb', line 4 def children @children end |
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/sass/tree/node.rb', line 6 def filename @filename end |
#line ⇒ Object
Returns the value of attribute line.
5 6 7 |
# File 'lib/sass/tree/node.rb', line 5 def line @line end |
Instance Method Details
#<<(child) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/sass/tree/node.rb', line 14 def <<(child) if msg = invalid_child?(child) raise Sass::SyntaxError.new(msg, child.line) end @children << child end |
#==(other) ⇒ Object
26 27 28 |
# File 'lib/sass/tree/node.rb', line 26 def ==(other) self.class == other.class && other.children == children end |
#last ⇒ Object
We need this because Node duck types as an Array in engine.rb
22 23 24 |
# File 'lib/sass/tree/node.rb', line 22 def last children.last end |
#perform(environment) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/sass/tree/node.rb', line 42 def perform(environment) _perform(environment) rescue Sass::SyntaxError => e e.sass_line ||= line raise e end |
#to_s ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sass/tree/node.rb', line 30 def to_s result = String.new children.each do |child| if child.is_a? AttrNode raise Sass::SyntaxError.new('Attributes aren\'t allowed at the root of a document.', child.line) else result << "#{child.to_s(1)}" + (@style == :compressed ? '' : "\n") end end @style == :compressed ? result+"\n" : result[0...-1] end |
#to_sass(opts = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/sass/css.rb', line 9 def to_sass(opts = {}) result = '' children.each do |child| result << "#{child.to_sass(0, opts)}\n" end result end |