Class: RedshiftConnector::UrlDataFile

Inherits:
AbstractDataFile show all
Defined in:
lib/redshift_connector/url_data_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractDataFile

#data_object?, #each_row, #gzipped_object?

Constructor Details

#initialize(url, reader_class:) ⇒ UrlDataFile

Returns a new instance of UrlDataFile.



7
8
9
10
# File 'lib/redshift_connector/url_data_file.rb', line 7

def initialize(url, reader_class:)
  super reader_class: reader_class
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



12
13
14
# File 'lib/redshift_connector/url_data_file.rb', line 12

def url
  @url
end

Instance Method Details

#keyObject



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

def key
  @url.path
end

#openObject



18
19
20
21
22
23
24
25
26
# File 'lib/redshift_connector/url_data_file.rb', line 18

def open
  http = Net::HTTP.new(@url.host, @url.port)
  http.use_ssl = (@url.scheme.downcase == 'https')
  content = http.start {
    res = http.get(@url.request_uri)
    res.body
  }
  StringIO.new(content)
end