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, #options

Instance Method Summary collapse

Methods inherited from Node

#<<, #last, #perform, #render, #style, #to_sass

Constructor Details

#initialize(value, silent) ⇒ CommentNode

Returns a new instance of CommentNode.



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

def initialize(value, silent)
  @lines = []
  @value = value[2..-1].strip
  @silent = silent
  super()
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

#silentObject

Returns the value of attribute silent.



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

def silent
  @silent
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



16
17
18
# File 'lib/sass/tree/comment_node.rb', line 16

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

#invisible?Boolean

Returns:

  • (Boolean)


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

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

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



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

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