Class: Sass::Tree::CommentNode

Inherits:
Node
  • Object
show all
Defined in:
/home/nweiz/code/sass-site/.sass/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, #source_range

Instance Method Summary (collapse)

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

Parameters:



31
32
33
34
35
# File '/home/nweiz/code/sass-site/.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.

Returns:

  • (String)


20
21
22
# File '/home/nweiz/code/sass-site/.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.

Returns:

  • (Symbol)


27
28
29
# File '/home/nweiz/code/sass-site/.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.

Returns:



13
14
15
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/comment_node.rb', line 13

def value
  @value
end

Instance Method Details

- (Boolean) ==(other)

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



42
43
44
# File '/home/nweiz/code/sass-site/.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.)

Returns:

  • (Boolean)


52
53
54
55
56
57
58
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/comment_node.rb', line 52

def invisible?
  case @type
  when :loud; false
  when :silent; true
  else; style == :compressed
  end
end

- (Integer) lines

Returns the number of lines in the comment.

Returns:

  • (Integer)


63
64
65
66
67
68
# File '/home/nweiz/code/sass-site/.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