Class: Sass::Tree::CommentNode
- Defined in:
- lib/sass/tree/comment_node.rb
Overview
A static node representing a Sass comment (silent or loud).
Instance Attribute Summary collapse
-
#loud ⇒ Boolean
Whether the comment is loud.
-
#resolved_value ⇒ String
The text of the comment after any interpolated SassScript has been resolved.
-
#silent ⇒ Boolean
Whether or not the comment is silent (that is, doesn't output to CSS).
-
#value ⇒ Array<String, Sass::Script::Node>
The text of the comment, not including
/*
and*/
.
Attributes inherited from Node
#children, #filename, #has_children, #line, #options
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares the contents of two comments.
-
#initialize(value, silent, loud) ⇒ CommentNode
constructor
A new instance of CommentNode.
-
#invisible? ⇒ Boolean
Returns
true
if this is a silent comment or the current style doesn't render comments. -
#lines ⇒ Fixnum
Returns the number of lines in the comment.
Methods inherited from Node
#<<, #balance, #deep_copy, #do_extend, #each, #style, #to_s, #to_sass, #to_scss
Constructor Details
#initialize(value, silent, loud) ⇒ CommentNode
Returns a new instance of CommentNode.
38 39 40 41 42 43 |
# File 'lib/sass/tree/comment_node.rb', line 38
def initialize(value, silent, loud)
@value = Sass::Util.with_extracted_values(value) {|str| normalize_indentation str}
@silent = silent
@loud = loud
super()
end
|
Instance Attribute Details
#loud ⇒ Boolean
Whether the comment is loud.
Loud comments start with ! and force the comment to be generated irrespective of compilation settings or the comment syntax used.
28 29 30 |
# File 'lib/sass/tree/comment_node.rb', line 28
def loud
@loud
end
|
#resolved_value ⇒ String
The text of the comment after any interpolated SassScript has been resolved. Only set once Visitors::Perform has been run.
20 21 22 |
# File 'lib/sass/tree/comment_node.rb', line 20
def resolved_value
@resolved_value
end
|
#silent ⇒ Boolean
Whether or not the comment is silent (that is, doesn't output to CSS).
33 34 35 |
# File 'lib/sass/tree/comment_node.rb', line 33
def silent
@silent
end
|
#value ⇒ Array<String, Sass::Script::Node>
The text of the comment, not including /*
and */
.
Interspersed with Script::Nodes representing #{}
-interpolation
if this is a loud comment.
13 14 15 |
# File 'lib/sass/tree/comment_node.rb', line 13
def value
@value
end
|
Instance Method Details
#==(other) ⇒ Boolean
Compares the contents of two comments.
50 51 52 |
# File 'lib/sass/tree/comment_node.rb', line 50
def ==(other)
self.class == other.class && value == other.value && silent == other.silent && loud == other.loud
end
|
#invisible? ⇒ Boolean
Returns true
if this is a silent comment
or the current style doesn't render comments.
Comments starting with ! are never invisible (and the ! is removed from the output.)
60 61 62 63 64 65 66 |
# File 'lib/sass/tree/comment_node.rb', line 60
def invisible?
if @loud
return false
else
@silent || (style == :compressed)
end
end
|
#lines ⇒ Fixnum
Returns the number of lines in the comment.
71 72 73 74 75 76 |
# File 'lib/sass/tree/comment_node.rb', line 71
def lines
@value.inject(0) do |s, e|
next s + e.count("\n") if e.is_a?(String)
next s
end
end
|