Sha256: 315984ac54968cf5c8350fd1cd9a066e86852882162b945498dee4e1cb6ceda3

Contents?: true

Size: 662 Bytes

Versions: 5

Compression:

Stored size: 662 Bytes

Contents

require 'date'

module HistoricoAtivos
  class ParserHeader
    def parse(row)
      read_header row if row.start_with?("00")
    end

    def read_header(row)
      header = Header.new
      header.nome_arquivo = read_nome_arquivo row
      header.codigo_origem = read_codigo_origem row
      header.data_geracao = read_data_geracao row
      header
    end

    def read_nome_arquivo(row)
      row[02..14].strip
    end

    def read_codigo_origem(row)
      row[15..22].strip
    end

    def read_data_geracao(row)
      year = row[23..26]
      month = row[27..28]
      day = row[29..30]
      Date.new(year.to_i, month.to_i, day.to_i)
    end 
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bovespa_ingestion-0.3.2 lib/historico_ativos/parser_header.rb
bovespa_ingestion-0.3.1 lib/historico_ativos/parser_header.rb
bovespa_ingestion-0.3.0 lib/historico_ativos/parser_header.rb
bovespa_ingestion-0.2.0 lib/historico_ativos/parser_header.rb
bovespa_ingestion-0.1.0 lib/historico_ativos/parser_header.rb