Sha256: db63b2a27a43131c8ad27e51070cd2d3cc9827c94d6ff802f2c0295e9775c4ee
Contents?: true
Size: 958 Bytes
Versions: 4
Compression:
Stored size: 958 Bytes
Contents
# coding: utf-8 require 'net/ftp' require 'dech/yahoo/csv' module Dech class Yahoo class FTP DEFAULT_HOST = "yjftp.yahoofs.jp" DEFAULT_PATH = "/data_spy.csv" attr_accessor :products, :username, :host, :path def initialize(args={}) @products = args[:products] || [] @username = args[:username] @password = args[:password] @host = args[:host] || DEFAULT_HOST @path = args[:path] || DEFAULT_PATH end def csv Dech::Yahoo::CSV.new(@products) end def ready? ftp_connection{|ftp| !ftp.nlst(File.dirname(@path)).include?(@path) } end def upload! ftp_connection{|ftp| ftp.storlines("STOR #{@path}", csv) } true end def upload ready? && upload! end private def ftp_connection Net::FTP.open(@host, @username, @password){|ftp| yield(ftp) } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dech-0.1.0 | lib/dech/yahoo/ftp.rb |
dech-0.0.7 | lib/dech/yahoo/ftp.rb |
dech-0.0.6 | lib/dech/yahoo/ftp.rb |
dech-0.0.5 | lib/dech/yahoo/ftp.rb |