Class: Estratto::Parser
- Inherits:
-
Object
- Object
- Estratto::Parser
- Defined in:
- lib/estratto/parser.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#layout ⇒ Object
readonly
Returns the value of attribute layout.
Instance Method Summary collapse
-
#initialize(file_path, layout) ⇒ Parser
constructor
A new instance of Parser.
- #perform ⇒ Object
- #raw_content ⇒ Object
Constructor Details
#initialize(file_path, layout) ⇒ Parser
Returns a new instance of Parser.
8 9 10 11 |
# File 'lib/estratto/parser.rb', line 8 def initialize(file_path, layout) @file_path = file_path @layout = layout end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
6 7 8 |
# File 'lib/estratto/parser.rb', line 6 def file_path @file_path end |
#layout ⇒ Object (readonly)
Returns the value of attribute layout.
6 7 8 |
# File 'lib/estratto/parser.rb', line 6 def layout @layout end |
Instance Method Details
#perform ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/estratto/parser.rb', line 13 def perform @data ||= raw_content.map do |line| register_layout = layout.register_fields_for(line[layout.prefix_range]) next if register_layout.nil? Register.new(line, register_layout).refine end.compact end |
#raw_content ⇒ Object
21 22 23 |
# File 'lib/estratto/parser.rb', line 21 def raw_content @raw_data = Content.for(file_path) end |