Class: HamlLint::Tree::HamlCommentNode

Inherits:
Node
  • Object
show all
Defined in:
lib/haml_lint/tree/haml_comment_node.rb

Overview

Represents a HAML comment node.

Instance Attribute Summary

Attributes inherited from Node

#children, #line, #parent, #type

Instance Method Summary collapse

Methods inherited from Node

#comment_configuration, #disabled?, #each, #initialize, #inspect, #line_numbers, #lines, #next_node, #predecessor, #source_code, #subsequents, #successor

Constructor Details

This class inherits a constructor from HamlLint::Tree::Node

Instance Method Details

#directivesObject


8
9
10
11
12
# File 'lib/haml_lint/tree/haml_comment_node.rb', line 8

def directives
  directives = super
  directives << contained_directives
  directives.flatten
end

#textString

Returns the full text content of this comment, including newlines if a single comment spans multiple lines.

Returns:

  • (String)

18
19
20
21
22
23
24
25
26
# File 'lib/haml_lint/tree/haml_comment_node.rb', line 18

def text
  content = source_code
  indent = content[/^ */]

  content.gsub(/^#{indent}/, '')
         .gsub(/^-#/, '')
         .gsub(/^  /, '')
         .rstrip
end