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.

Constant Summary collapse

STRING_SOURCE =

File name given to source code parsed from just a string.

'(string)'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ Document

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

Options Hash (options):

  • :file (String)

    file name of document that was parsed

Raises:

  • (Slim::Parser::Error)

    if there was a problem parsing the document



30
31
32
33
34
35
# File 'lib/slim_lint/document.rb', line 30

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

  process_source(source)
end

Instance Attribute Details

#configSlimLint::Configuration (readonly)



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

def config
  @config
end

#fileString (readonly)



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

def file
  @file
end

#sexpSlimLint::Sexp (readonly)



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

def sexp
  @sexp
end

#sourceString (readonly)



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

def source
  @source
end

#source_linesArray<String> (readonly)



22
23
24
# File 'lib/slim_lint/document.rb', line 22

def source_lines
  @source_lines
end