class Sunnyside::IncomingFiles

Attributes

file_records[R]
ftp[R]
ftp_files[R]
name[R]

Public Class Methods

new(ftp, name) click to toggle source
# File lib/sunnyside/ftp.rb, line 50
def initialize(ftp, name)
  @file_records = Dir["#{DRIVE}/sunnyside-files/ftp/835/#{name}/*.pgp"].map { |file| File.basename(file).gsub(/^.{11}/, '') }
  @ftp_files    = ftp.nlst.select { |file| file.include?('835') }
  @ftp          = ftp
  @name         = name
end

Public Instance Methods

download_file(file) click to toggle source
# File lib/sunnyside/ftp.rb, line 73
def download_file(file)
  puts "Downloading #{file}..."
  ftp.getbinaryfile(file, "#{DRIVE}/sunnyside-files/ftp/835/#{name}/#{timestamp(file)}")
end
download_files() click to toggle source
# File lib/sunnyside/ftp.rb, line 61
def download_files
  if new_files.size > 0
    new_files.each { |file| download_file(file) }
  else
    puts "No new files to download."
  end
end
new_files() click to toggle source
# File lib/sunnyside/ftp.rb, line 57
def new_files
  ftp_files.select { |file| !file_records.include?(file) }
end
timestamp(file) click to toggle source
# File lib/sunnyside/ftp.rb, line 69
def timestamp(file)
  ftp.mtime(file).strftime('%Y-%m-%d') + "-#{File.basename(file)}"
end