Class: QueueryClient::DataFile

Inherits:
Object
  • Object
show all
Defined in:
lib/queuery_client/data_file.rb

Overview

abstract class

Direct Known Subclasses

S3DataFile, UrlDataFile

Instance Method Summary collapse

Instance Method Details

#data_object?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/queuery_client/data_file.rb', line 6

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

#each_row(&block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/queuery_client/data_file.rb', line 14

def each_row(&block)
  return enum_for(:each_row) if !block_given?

  f = open
  begin
    if gzipped_object?
      f = Zlib::GzipReader.new(f)
    end
    RedshiftCsvFile.new(f).each do |row|
      yield row
    end
  ensure
    f.close
  end

  self
end

#gzipped_object?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/queuery_client/data_file.rb', line 10

def gzipped_object?
  File.extname(key) == '.gz'
end