Class: HamlLint::Document
- Inherits:
-
Object
- Object
- HamlLint::Document
- Defined in:
- lib/haml_lint/document.rb
Overview
Represents a parsed Haml 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
-
#config ⇒ HamlLint::Configuration
readonly
Configuration used to parse template.
-
#file ⇒ String
readonly
Haml template file path.
-
#source ⇒ String
readonly
Original source code.
-
#source_lines ⇒ Array<String>
readonly
Original source code as an array of lines.
-
#tree ⇒ HamlLint::Tree::Node
readonly
Root of the parse tree.
Instance Method Summary collapse
-
#initialize(source, options) ⇒ Document
constructor
Parses the specified Haml code into a Document.
Constructor Details
#initialize(source, options) ⇒ Document
Parses the specified Haml code into a HamlLint::Document.
32 33 34 35 36 37 |
# File 'lib/haml_lint/document.rb', line 32 def initialize(source, ) @config = [:config] @file = .fetch(:file, STRING_SOURCE) process_source(source) end |
Instance Attribute Details
#config ⇒ HamlLint::Configuration (readonly)
Returns Configuration used to parse template.
12 13 14 |
# File 'lib/haml_lint/document.rb', line 12 def config @config end |
#file ⇒ String (readonly)
Returns Haml template file path.
15 16 17 |
# File 'lib/haml_lint/document.rb', line 15 def file @file end |
#source ⇒ String (readonly)
Returns original source code.
21 22 23 |
# File 'lib/haml_lint/document.rb', line 21 def source @source end |
#source_lines ⇒ Array<String> (readonly)
Returns original source code as an array of lines.
24 25 26 |
# File 'lib/haml_lint/document.rb', line 24 def source_lines @source_lines end |
#tree ⇒ HamlLint::Tree::Node (readonly)
Returns Root of the parse tree.
18 19 20 |
# File 'lib/haml_lint/document.rb', line 18 def tree @tree end |