Class: Sass::Tree::CommentNode
- Inherits:
- Node
- Object
- Node
- Sass::Tree::CommentNode
- Defined in:
- /Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/comment_node.rb
Overview
A static node representing a Sass comment (silent or loud).
Instance Attribute Summary (collapse)
- - (String) resolved_value
The text of the comment after any interpolated SassScript has been resolved.
- - (Symbol) type
The type of the comment.
- - (Array<String, Sass::Script::Tree::Node>) value
The text of the comment, not including
/*
and*/
.
Attributes inherited from Node
#children, #filename, #has_children, #line, #options, #source_range
Instance Method Summary (collapse)
- - (Boolean) ==(other)
Compares the contents of two comments.
- - (CommentNode) initialize(value, type) constructor
A new instance of CommentNode.
- - (Boolean) invisible?
Returns
true
if this is a silent comment or the current style doesn’t render comments. - - (Fixnum) lines
Returns the number of lines in the comment.
Methods inherited from Node
#<<, #balance, #bubbles?, #css, #css_with_sourcemap, #deep_copy, #each, #inspect, #style, #to_sass, #to_scss
Constructor Details
- (CommentNode) initialize(value, type)
Returns a new instance of CommentNode
31 32 33 34 35 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/comment_node.rb', line 31
def initialize(value, type)
@value = Sass::Util.with_extracted_values(value) {|str| normalize_indentation str}
@type = type
super()
end |
Instance Attribute Details
- (String) resolved_value
The text of the comment after any interpolated SassScript has been resolved. Only set once Visitors::Perform has been run.
20 21 22 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/comment_node.rb', line 20
def resolved_value
@resolved_value
end |
- (Symbol) type
The type of the comment. :silent
means it’s never output to CSS, :normal
means it’s output in every compile mode except :compressed
, and :loud
means it’s output even in :compressed
.
27 28 29 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/comment_node.rb', line 27
def type
@type
end |
- (Array<String, Sass::Script::Tree::Node>) value
The text of the comment, not including /*
and */
. Interspersed with Script::Tree::Nodes representing #{}
-interpolation if this is a loud comment.
13 14 15 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/comment_node.rb', line 13
def value
@value
end |
Instance Method Details
- (Boolean) ==(other)
Compares the contents of two comments.
42 43 44 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/comment_node.rb', line 42
def ==(other)
self.class == other.class && value == other.value && type == other.type
end |
- (Boolean) invisible?
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.)
52 53 54 55 56 57 58 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/comment_node.rb', line 52
def invisible?
case @type
when :loud; false
when :silent; true
else; style == :compressed
end
end |
- (Fixnum) lines
Returns the number of lines in the comment.
63 64 65 66 67 68 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/comment_node.rb', line 63
def lines
@value.inject(0) do |s, e|
next s + e.count("\n") if e.is_a?(String)
next s
end
end |