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

#is_strict_locals?Boolean

Returns whether this comment contains a ‘locals` directive.

Returns:

  • (Boolean)


31
32
33
# File 'lib/haml_lint/tree/haml_comment_node.rb', line 31

def is_strict_locals?
  text.lstrip.start_with?('locals:')
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