Class: SecEdgar::FtpClient
- Inherits:
-
Object
- Object
- SecEdgar::FtpClient
- Includes:
- Singleton
- Defined in:
- lib/sec_edgar/ftp_client.rb
Instance Method Summary collapse
- #connect ⇒ Object
- #fetch(remote_url, local_url) ⇒ Object
-
#initialize ⇒ FtpClient
constructor
A new instance of FtpClient.
- #login ⇒ Object
Constructor Details
#initialize ⇒ FtpClient
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 login at_exit do puts "Closing SecEdgar::FtpClient..." @ftp.close end end |
Instance Method Details
#connect ⇒ Object
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. 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 |
#login ⇒ Object
28 29 30 31 32 33 |
# File 'lib/sec_edgar/ftp_client.rb', line 28 def login @ftp.login rescue => e puts "SecEdgar::FtpClient login failed" puts e. end |