Class: AriFetch::Engine
- Inherits:
-
Object
- Object
- AriFetch::Engine
- Defined in:
- lib/ari_fetch.rb
Instance Attribute Summary collapse
-
#ftp_files ⇒ Object
Returns the value of attribute ftp_files.
-
#ftp_instance ⇒ Object
Returns the value of attribute ftp_instance.
-
#ftp_url ⇒ Object
Returns the value of attribute ftp_url.
-
#options ⇒ Object
Returns the value of attribute options.
-
#password ⇒ Object
Returns the value of attribute password.
-
#read_files ⇒ Object
Returns the value of attribute read_files.
-
#unread_files ⇒ Object
Returns the value of attribute unread_files.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #fetch_vehicles_from_files(how_many = 1) ⇒ Object
-
#initialize(ftp_url, username, password, options = {}) ⇒ Engine
constructor
A new instance of Engine.
- #login ⇒ Object
Constructor Details
#initialize(ftp_url, username, password, options = {}) ⇒ Engine
Returns a new instance of Engine.
14 15 16 |
# File 'lib/ari_fetch.rb', line 14 def initialize(ftp_url, username, password, = {}) @ftp_url, @username, @password, = ftp_url, username, password, end |
Instance Attribute Details
#ftp_files ⇒ Object
Returns the value of attribute ftp_files.
11 12 13 |
# File 'lib/ari_fetch.rb', line 11 def ftp_files @ftp_files end |
#ftp_instance ⇒ Object
Returns the value of attribute ftp_instance.
11 12 13 |
# File 'lib/ari_fetch.rb', line 11 def ftp_instance @ftp_instance end |
#ftp_url ⇒ Object
Returns the value of attribute ftp_url.
11 12 13 |
# File 'lib/ari_fetch.rb', line 11 def ftp_url @ftp_url end |
#options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'lib/ari_fetch.rb', line 11 def end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/ari_fetch.rb', line 11 def password @password end |
#read_files ⇒ Object
Returns the value of attribute read_files.
11 12 13 |
# File 'lib/ari_fetch.rb', line 11 def read_files @read_files end |
#unread_files ⇒ Object
Returns the value of attribute unread_files.
11 12 13 |
# File 'lib/ari_fetch.rb', line 11 def unread_files @unread_files end |
#username ⇒ Object
Returns the value of attribute username.
11 12 13 |
# File 'lib/ari_fetch.rb', line 11 def username @username end |
Instance Method Details
#fetch_vehicles_from_files(how_many = 1) ⇒ Object
30 31 32 |
# File 'lib/ari_fetch.rb', line 30 def fetch_vehicles_from_files(how_many=1) unread_files.first(how_many).map {|file| AriFetch::AriReadFile.where(name: file).first_or_create(data_read: false).fetch_data(ftp_instance, include_cancel?) }.flatten! end |
#login ⇒ Object
34 35 36 37 38 39 |
# File 'lib/ari_fetch.rb', line 34 def login ftp_instance.connect(ftp_url, 21) ftp_instance.login(username, password) ftp_instance.passive = true ftp_instance.chdir('/') end |