Sha256: 419d9bbd7ffd77fb48a1a75d213b06cc6460fa64ce38238b0cfa995bf800c963

Contents?: true

Size: 580 Bytes

Versions: 3

Compression:

Stored size: 580 Bytes

Contents

require_relative 'register'
require_relative 'content'

module Estratto
  class Parser
    attr_reader :file_path, :layout

    def initialize(file_path, layout)
      @file_path = file_path
      @layout = layout
    end

    def perform
      @data ||= raw_content.map.with_index do |line, index|
        register_layout = layout.register_fields_for(line[layout.prefix_range])
        next if register_layout.nil?
        Register.new(line, index, register_layout).refine
      end.compact
    end

    def raw_content
      @raw_data = Content.for(file_path)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
estratto-1.0.5 lib/estratto/parser.rb
estratto-1.0.4 lib/estratto/parser.rb
estratto-1.0.3 lib/estratto/parser.rb