Class: Sass::Tree::CommentNode

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

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #filename, #line

Instance Method Summary collapse

Methods inherited from Node

#<<, #last, #perform, #to_sass

Constructor Details

#initialize(value, options) ⇒ CommentNode

Returns a new instance of CommentNode.



8
9
10
11
12
# File 'lib/sass/tree/comment_node.rb', line 8

def initialize(value, options)
  @lines = []
  @value = value[2..-1].strip
  super(options)
end

Instance Attribute Details

#linesObject

Returns the value of attribute lines.



5
6
7
# File 'lib/sass/tree/comment_node.rb', line 5

def lines
  @lines
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/sass/tree/comment_node.rb', line 6

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
# File 'lib/sass/tree/comment_node.rb', line 14

def ==(other)
  self.class == other.class && value == other.value && lines == other.lines
end

#invisible?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/sass/tree/comment_node.rb', line 30

def invisible?
  @style == :compressed || silent?
end

#silent?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/sass/tree/comment_node.rb', line 18

def silent?
  !!@options[:silent]
end

#to_s(tabs = 0, parent_name = nil) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/sass/tree/comment_node.rb', line 22

def to_s(tabs = 0, parent_name = nil)
  return if invisible?

  spaces = '  ' * (tabs - 1)
  spaces + "/* " + ([value] + lines.map {|l| l.text}).
    map{|l| l.sub(%r{ ?\*/ *$},'')}.join(@style == :compact ? ' ' : "\n#{spaces} * ") + " */"
end