Class: HamlLint::Tree::RootNode

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

Overview

Represents the root node of a HAML document that contains all other nodes.

Instance Attribute Summary

Attributes inherited from Node

#children, #line, #parent, #type

Instance Method Summary collapse

Methods inherited from Node

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

Constructor Details

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

Instance Method Details

#fileString

The name fo the file parsed to build this tree.

Returns:

  • (String)

    a file name



11
12
13
# File 'lib/haml_lint/tree/root_node.rb', line 11

def file
  @document.file
end

#node_for_line(line) ⇒ HamlLint::Node

Gets the node of the syntax tree for a given line number.

Parameters:

  • line (Integer)

    the line number of the node

Returns:

  • (HamlLint::Node)


19
20
21
22
23
# File 'lib/haml_lint/tree/root_node.rb', line 19

def node_for_line(line)
  find(-> { HamlLint::Tree::NullNode.new }) do |node|
    node.line_numbers.cover?(line) && node != self
  end
end