Class: RedshiftConnector::AbstractDataFile
- Inherits:
-
Object
- Object
- RedshiftConnector::AbstractDataFile
- Defined in:
- lib/redshift_connector/abstract_data_file.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#data_object? ⇒ Boolean
abstract open.
- #each_row(&block) ⇒ Object
- #gzipped_object? ⇒ Boolean
-
#initialize(reader_class:) ⇒ AbstractDataFile
constructor
A new instance of AbstractDataFile.
Constructor Details
#initialize(reader_class:) ⇒ AbstractDataFile
Returns a new instance of AbstractDataFile.
5 6 7 |
# File 'lib/redshift_connector/abstract_data_file.rb', line 5 def initialize(reader_class:) @reader_class = reader_class end |
Instance Method Details
#data_object? ⇒ Boolean
abstract open
23 24 25 |
# File 'lib/redshift_connector/abstract_data_file.rb', line 23 def data_object? @reader_class.data_object?(key) end |
#each_row(&block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/redshift_connector/abstract_data_file.rb', line 9 def each_row(&block) f = open begin if gzipped_object? f = Zlib::GzipReader.new(f) end @reader_class.new(f).each(&block) ensure f.close end end |
#gzipped_object? ⇒ Boolean
27 28 29 |
# File 'lib/redshift_connector/abstract_data_file.rb', line 27 def gzipped_object? File.extname(key) == '.gz' end |