Class: RailsRouteChecker::Parsers::HamlParser::Document
- Inherits:
-
Object
- Object
- RailsRouteChecker::Parsers::HamlParser::Document
- Defined in:
- lib/rails-route-checker/parsers/haml_parser/document.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_lines ⇒ Object
readonly
Returns the value of attribute source_lines.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
-
#initialize(source) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(source) ⇒ Document
Returns a new instance of Document.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails-route-checker/parsers/haml_parser/document.rb', line 9 def initialize(source) @source = source.force_encoding(Encoding::UTF_8) @source_lines = @source.split(/\r\n|\r|\n/) version = Gem::Version.new(Haml::VERSION).approximate_recommendation original_tree = case version when '~> 4.0', '~> 4.1' = Haml::Options.new Haml::Parser.new(@source, ).parse when '~> 5.0', '~> 5.1', '~> 5.2' = Haml::Options.new Haml::Parser.new().call(@source) when '~> 6.0', '~> 6.1', '~> 6.2', '~> 6.3' Haml::Parser.new({}).call(@source) else raise "Cannot handle Haml version: #{version}" end @tree = process_tree(original_tree) end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/rails-route-checker/parsers/haml_parser/document.rb', line 7 def source @source end |
#source_lines ⇒ Object (readonly)
Returns the value of attribute source_lines.
7 8 9 |
# File 'lib/rails-route-checker/parsers/haml_parser/document.rb', line 7 def source_lines @source_lines end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
7 8 9 |
# File 'lib/rails-route-checker/parsers/haml_parser/document.rb', line 7 def tree @tree end |