Sha256: f8d4eac0cdf984574ca320bcdf9431373cb30cd3f486fcfc918349554a736c24
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module HylaFAX class SendFax < Command DEFAULT_TMP_DIR = 'tmp' attr_reader :dialstring, :document, :tmp_dir, :job_id def initialize(opts = {}) super @tmp_dir = opts.fetch(:tmp_dir) { DEFAULT_TMP_DIR } @dialstring = opts.fetch(:dialstring) @document = opts.fetch(:document) @job_id = nil end def run connect login upload_document create_new_job set_lasttime set_dialstring set_document submit_job job_id end private def upload_document ftp.put(document, remote_document) unless document_uploaded? end def remote_document File.join(tmp_dir, document_filename) end def document_filename @document_filename ||= Digest::MD5.file(document).hexdigest end def document_uploaded? ftp.list(tmp_dir).map { |l| l.split.last }.include?(document_filename) end def create_new_job /jobid:\s+(\d+)\s+/ =~ ftp.sendcmd('JNEW') @job_id = $1.to_i if $1 end def set_lasttime ftp.sendcmd('JPARM LASTTIME 000259') end def set_dialstring ftp.sendcmd("JPARM DIALSTRING \"#{dialstring}\"") end def set_document ftp.sendcmd("JPARM DOCUMENT \"#{remote_document}\"") end def submit_job ftp.sendcmd('JSUBM') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hylafax-0.2.0 | lib/hylafax/send_fax.rb |