Class: RedshiftConnector::Reader::TSV

Inherits:
Abstract
  • Object
show all
Defined in:
lib/redshift_connector/reader/tsv.rb

Overview

Parses TSV (Tab Separated Format) files.

Constant Summary

Constants inherited from Abstract

Abstract::READER_CLASSES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

declare_reader, get_reader_class

Constructor Details

#initialize(f) ⇒ TSV

Returns a new instance of TSV.



14
15
16
# File 'lib/redshift_connector/reader/tsv.rb', line 14

def initialize(f)
  @f = f
end

Class Method Details

.data_object?(key) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/redshift_connector/reader/tsv.rb', line 10

def self.data_object?(key)
  /\.tsv(?:\.|\z)/ =~ File.basename(key)
end

Instance Method Details

#each(&block) ⇒ Object



18
19
20
21
22
# File 'lib/redshift_connector/reader/tsv.rb', line 18

def each(&block)
  @f.each_line do |line|
    yield line.chomp.split("\t", -1)
  end
end