Class: ERBLint::ProcessedSource
- Inherits:
-
Object
- Object
- ERBLint::ProcessedSource
- Defined in:
- lib/erb_lint/processed_source.rb
Instance Attribute Summary collapse
-
#file_content ⇒ Object
readonly
Returns the value of attribute file_content.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #ast ⇒ Object
-
#initialize(filename, file_content) ⇒ ProcessedSource
constructor
A new instance of ProcessedSource.
- #source_buffer ⇒ Object
- #to_source_range(range) ⇒ Object
Constructor Details
#initialize(filename, file_content) ⇒ ProcessedSource
Returns a new instance of ProcessedSource.
7 8 9 10 11 |
# File 'lib/erb_lint/processed_source.rb', line 7 def initialize(filename, file_content) @filename = filename @file_content = file_content @parser = BetterHtml::Parser.new(source_buffer, template_language: :html) end |
Instance Attribute Details
#file_content ⇒ Object (readonly)
Returns the value of attribute file_content.
5 6 7 |
# File 'lib/erb_lint/processed_source.rb', line 5 def file_content @file_content end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/erb_lint/processed_source.rb', line 5 def filename @filename end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
5 6 7 |
# File 'lib/erb_lint/processed_source.rb', line 5 def parser @parser end |
Instance Method Details
#ast ⇒ Object
13 14 15 |
# File 'lib/erb_lint/processed_source.rb', line 13 def ast @parser.ast end |
#source_buffer ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/erb_lint/processed_source.rb', line 17 def source_buffer @source_buffer ||= begin buffer = Parser::Source::Buffer.new(filename) buffer.source = file_content buffer end end |
#to_source_range(range) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/erb_lint/processed_source.rb', line 25 def to_source_range(range) range = (range.begin_pos...range.end_pos) if range.is_a?(::Parser::Source::Range) BetterHtml::Tokenizer::Location.new( source_buffer, range.begin, range.exclude_end? ? range.end : range.end + 1, ) end |