class Dech::Dena::FTP

Constants

DEFAULT_HOST
DEFAULT_PATH

Attributes

host[RW]
path[RW]
products[RW]
username[RW]

Public Class Methods

new(args={}) click to toggle source
# File lib/dech/dena/ftp.rb, line 14
def initialize(args={})
  @products = args[:products] || []
  @username = args[:username]
  @password = args[:password]
  @host     = args[:host] || DEFAULT_HOST
  @path     = args[:path] || DEFAULT_PATH
  @local_address = args[:local_address]
  @local_port    = args[:local_port]
end

Public Instance Methods

csv() click to toggle source
# File lib/dech/dena/ftp.rb, line 24
def csv
  Dech::Dena::CSV.new(@products)
end
ready?() click to toggle source
# File lib/dech/dena/ftp.rb, line 28
def ready?
  true
end
upload() click to toggle source
# File lib/dech/dena/ftp.rb, line 37
def upload
  ready? && upload!
end
upload!() click to toggle source
# File lib/dech/dena/ftp.rb, line 32
def upload!
  ftp_connection{|ftp| ftp.storlines("STOR #{@path}", csv) }
  true
end

Private Instance Methods

ftp_connection() { |ftp| ... } click to toggle source
# File lib/dech/dena/ftp.rb, line 43
def ftp_connection
   Net::FTP.open(@host, @username, @password) do |ftp|
     ftp.port(@local_address, @local_port) if @local_address || @local_port
     yield(ftp)
   end
end