Class: LintTrappings::Document Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/lint_trappings/document.rb

Overview

This class is abstract.

Represents a parsed document and its associated metadata.

Implementors should implement the #process_source method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, config, options = {}) ⇒ Document

Parses the specified Slim code into a LintTrappings::Document.

Parameters:

Options Hash (options):

  • :path (String)

    path of document that was parsed


27
28
29
30
31
32
33
34
# File 'lib/lint_trappings/document.rb', line 27

def initialize(source, config, options = {})
  @config = config
  @path = options[:path]
  @source = source
  @source_lines = @source.split("\n")

  process_source(source)
end

Instance Attribute Details

#configLintTrappings::Configuration (readonly)

Returns configuration used to parse template.

Returns:


9
10
11
# File 'lib/lint_trappings/document.rb', line 9

def config
  @config
end

#pathString? (readonly)

Returns path of the file that was parsed, or nil if it was parsed directory from a string.

Returns:

  • (String, nil)

    path of the file that was parsed, or nil if it was parsed directory from a string


13
14
15
# File 'lib/lint_trappings/document.rb', line 13

def path
  @path
end

#sourceString (readonly)

Returns original source code.

Returns:

  • (String)

    original source code


16
17
18
# File 'lib/lint_trappings/document.rb', line 16

def source
  @source
end

#source_linesArray<String> (readonly)

Returns original source code as an array of lines.

Returns:

  • (Array<String>)

    original source code as an array of lines


19
20
21
# File 'lib/lint_trappings/document.rb', line 19

def source_lines
  @source_lines
end