Class: LintTrappings::Document Abstract
- Inherits:
-
Object
- Object
- LintTrappings::Document
- 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
-
#config ⇒ LintTrappings::Configuration
readonly
Configuration used to parse template.
-
#path ⇒ String?
readonly
Path of the file that was parsed, or nil if it was parsed directory from a string.
-
#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, config, options = {}) ⇒ Document
constructor
Parses the specified Slim code into a Document.
Constructor Details
#initialize(source, config, options = {}) ⇒ Document
Parses the specified Slim code into a LintTrappings::Document.
27 28 29 30 31 32 33 34 |
# File 'lib/lint_trappings/document.rb', line 27 def initialize(source, config, = {}) @config = config @path = [:path] @source = source @source_lines = @source.split("\n") process_source(source) end |
Instance Attribute Details
#config ⇒ LintTrappings::Configuration (readonly)
Returns configuration used to parse template.
9 10 11 |
# File 'lib/lint_trappings/document.rb', line 9 def config @config end |
#path ⇒ String? (readonly)
Returns 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 |
#source ⇒ String (readonly)
Returns original source code.
16 17 18 |
# File 'lib/lint_trappings/document.rb', line 16 def source @source end |
#source_lines ⇒ Array<String> (readonly)
Returns 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 |