Class: SlimLint::Document
- Inherits:
-
Object
- Object
- SlimLint::Document
- 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)'
Instance Attribute Summary collapse
-
#config ⇒ SlimLint::Configuration
readonly
Configuration used to parse template.
-
#file ⇒ String
readonly
Slim template file path.
-
#sexp ⇒ SlimLint::Sexp
readonly
Sexpression representing the parsed document.
-
#source ⇒ String
readonly
Original source code.
-
#source_lines ⇒ Array<String>
readonly
Original source code as an array of lines.
Instance Method Summary collapse
-
#initialize(source, options) ⇒ Document
constructor
Parses the specified Slim code into a Document.
Constructor Details
#initialize(source, options) ⇒ Document
Parses the specified Slim code into a SlimLint::Document.
28 29 30 31 32 33 |
# File 'lib/slim_lint/document.rb', line 28 def initialize(source, ) @config = [:config] @file = .fetch(:file, STRING_SOURCE) process_source(source) end |
Instance Attribute Details
#config ⇒ SlimLint::Configuration (readonly)
Returns Configuration used to parse template.
8 9 10 |
# File 'lib/slim_lint/document.rb', line 8 def config @config end |
#file ⇒ String (readonly)
Returns Slim template file path.
11 12 13 |
# File 'lib/slim_lint/document.rb', line 11 def file @file end |
#sexp ⇒ SlimLint::Sexp (readonly)
Returns Sexpression representing the parsed document.
14 15 16 |
# File 'lib/slim_lint/document.rb', line 14 def sexp @sexp end |
#source ⇒ String (readonly)
Returns original source code.
17 18 19 |
# File 'lib/slim_lint/document.rb', line 17 def source @source end |
#source_lines ⇒ Array<String> (readonly)
Returns original source code as an array of lines.
20 21 22 |
# File 'lib/slim_lint/document.rb', line 20 def source_lines @source_lines end |