Class: Sass::Tree::CommentNode

Inherits:
Node
  • Object
show all
Defined in:
lib/sass/tree/comment_node.rb

Overview

A static node representing a Sass comment (silent or loud).

See Also:

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #filename, #has_children, #line, #options

Instance Method Summary collapse

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.

Parameters:



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

#loudBoolean

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.

Returns:

  • (Boolean)


28
29
30
# File 'lib/sass/tree/comment_node.rb', line 28

def loud
  @loud
end

#resolved_valueString

The text of the comment after any interpolated SassScript has been resolved. Only set once Visitors::Perform has been run.

Returns:

  • (String)


20
21
22
# File 'lib/sass/tree/comment_node.rb', line 20

def resolved_value
  @resolved_value
end

#silentBoolean

Whether or not the comment is silent (that is, doesn't output to CSS).

Returns:

  • (Boolean)


33
34
35
# File 'lib/sass/tree/comment_node.rb', line 33

def silent
  @silent
end

#valueArray<String, Sass::Script::Node>

The text of the comment, not including /* and */. Interspersed with Script::Nodes representing #{}-interpolation if this is a loud comment.

Returns:



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.

Parameters:

  • other (Object)

    The object to compare with

Returns:

  • (Boolean)

    Whether or not this node and the other object are the same



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.)

Returns:

  • (Boolean)


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

#linesFixnum

Returns the number of lines in the comment.

Returns:

  • (Fixnum)


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