Class: Haml::I18n::Extractor::HamlReader
- Inherits:
-
Object
- Object
- Haml::I18n::Extractor::HamlReader
- Defined in:
- lib/haml-i18n-extractor/extraction/haml_reader.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ HamlReader
constructor
A new instance of HamlReader.
-
#metadata ⇒ Object
cache me?.
Constructor Details
#initialize(path) ⇒ HamlReader
Returns a new instance of HamlReader.
8 9 10 11 12 13 14 15 |
# File 'lib/haml-i18n-extractor/extraction/haml_reader.rb', line 8 def initialize(path) file = File.open(path, "r") @path = path @body = file.read file.rewind @lines = file.readlines file.rewind end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/haml-i18n-extractor/extraction/haml_reader.rb', line 6 def body @body end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
6 7 8 |
# File 'lib/haml-i18n-extractor/extraction/haml_reader.rb', line 6 def lines @lines end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/haml-i18n-extractor/extraction/haml_reader.rb', line 6 def path @path end |
Instance Method Details
#metadata ⇒ Object
cache me?
18 19 20 21 22 23 24 25 |
# File 'lib/haml-i18n-extractor/extraction/haml_reader.rb', line 18 def parser = Haml::I18n::Extractor::HamlParser.new(@body) = parser.flattened_values = {} # blank lines are missing! so api [] access per line in file, not by array index. .each{|line_data| .merge!(line_data[:line] => line_data) } end |