Class: RedshiftConnector::S3DataFile
- Inherits:
-
Object
- Object
- RedshiftConnector::S3DataFile
- Defined in:
- lib/redshift-connector/s3_data_file.rb
Instance Method Summary collapse
- #data_object? ⇒ Boolean
- #each_row(&block) ⇒ Object
- #gzipped_object? ⇒ Boolean
-
#initialize(object, reader_class:) ⇒ S3DataFile
constructor
A new instance of S3DataFile.
- #key ⇒ Object
Constructor Details
#initialize(object, reader_class:) ⇒ S3DataFile
Returns a new instance of S3DataFile.
5 6 7 8 |
# File 'lib/redshift-connector/s3_data_file.rb', line 5 def initialize(object, reader_class:) @object = object @reader_class = reader_class end |
Instance Method Details
#data_object? ⇒ Boolean
26 27 28 |
# File 'lib/redshift-connector/s3_data_file.rb', line 26 def data_object? @reader_class.data_object?(@object) end |
#each_row(&block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/redshift-connector/s3_data_file.rb', line 14 def each_row(&block) response = @object.get f = if gzipped_object? Zlib::GzipReader.new(response.body) else response.body end @reader_class.new(f).each(&block) ensure response.body.close if response end |
#gzipped_object? ⇒ Boolean
30 31 32 |
# File 'lib/redshift-connector/s3_data_file.rb', line 30 def gzipped_object? File.extname(@object.key) == '.gz' end |
#key ⇒ Object
10 11 12 |
# File 'lib/redshift-connector/s3_data_file.rb', line 10 def key @object.key end |