class Dech::Rakuten::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/rakuten/ftp.rb, line 13 def initialize(args={}) @products = args[:products] || [] @username = args[:username] @password = args[:password] @host = args[:host] || DEFAULT_HOST @path = args[:path] || DEFAULT_PATH end
Public Instance Methods
csv()
click to toggle source
# File lib/dech/rakuten/ftp.rb, line 21 def csv Dech::Rakuten::CSV.new(@products) end
ready?()
click to toggle source
# File lib/dech/rakuten/ftp.rb, line 25 def ready? ftp_connection{|ftp| !ftp.nlst(File.dirname(@path)).include?(@path) } end
upload()
click to toggle source
# File lib/dech/rakuten/ftp.rb, line 34 def upload ready? && upload! end
upload!()
click to toggle source
# File lib/dech/rakuten/ftp.rb, line 29 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/rakuten/ftp.rb, line 40 def ftp_connection Net::FTP.open(@host, @username, @password) do |ftp| ftp.passive = true yield(ftp) end end