Class: SlimLint::Document

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

Overview

Represents a parsed Slim document and its associated metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ Document

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

Parameters:

  • source (String)

    Slim code to parse

  • options (Hash)

Options Hash (options):

  • :file (String)

    file name of document that was parsed

Raises:

  • (Slim::Parser::Error)

    if there was a problem parsing the document



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

def initialize(source, options)
  @config = options[:config]
  @file = options.fetch(:file, nil)

  process_source(source)
end

Instance Attribute Details

#configSlimLint::Configuration (readonly)

Returns Configuration used to parse template.

Returns:



7
8
9
# File 'lib/slim_lint/document.rb', line 7

def config
  @config
end

#fileString (readonly)

Returns Slim template file path.

Returns:

  • (String)

    Slim template file path



10
11
12
# File 'lib/slim_lint/document.rb', line 10

def file
  @file
end

#sexpSlimLint::Sexp (readonly)

Returns Sexpression representing the parsed document.

Returns:



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

def sexp
  @sexp
end

#sourceString (readonly)

Returns original source code.

Returns:

  • (String)

    original source code



16
17
18
# File 'lib/slim_lint/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/slim_lint/document.rb', line 19

def source_lines
  @source_lines
end