Class: SecEdgar::FtpClient

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/sec_edgar/ftp_client.rb

Instance Method Summary collapse

Constructor Details

#initializeFtpClient

Returns a new instance of FtpClient.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/sec_edgar/ftp_client.rb', line 5

def initialize
  @ftp = Net::FTP.new
  @ftp.passive = true
  connect
  

  at_exit do
    puts "Closing SecEdgar::FtpClient..."
    @ftp.close
  end
end

Instance Method Details

#connectObject



21
22
23
24
25
26
# File 'lib/sec_edgar/ftp_client.rb', line 21

def connect
  @ftp.connect('ftp.sec.gov', 21)
rescue => e
  puts "SecEdgar::FtpClient connection failed"
  puts e.message
end

#fetch(remote_url, local_url) ⇒ Object



17
18
19
# File 'lib/sec_edgar/ftp_client.rb', line 17

def fetch(remote_url, local_url)
  @ftp.getbinaryfile(remote_url, local_url)
end

#loginObject



28
29
30
31
32
33
# File 'lib/sec_edgar/ftp_client.rb', line 28

def 
  @ftp.
rescue => e
  puts "SecEdgar::FtpClient login failed"
  puts e.message
end