Class: Haml::I18n::Extractor::HamlReader

Inherits:
Object
  • Object
show all
Defined in:
lib/haml-i18n-extractor/extraction/haml_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (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

#linesObject (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

#pathObject (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

#metadataObject

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)
  line_metadatas = parser.flattened_values
   = {}
  # blank lines are missing! so api [] access per line in file, not by array index.
  line_metadatas.each{|line_data| .merge!(line_data[:line] => line_data) }
  
end