Class: MailFakk2
Instance Attribute Summary collapse
-
#fax ⇒ Object
readonly
Returns the value of attribute fax.
Class Method Summary collapse
Instance Method Summary collapse
- #archive_path ⇒ Object
- #callfile_contents ⇒ Object
- #callfile_path ⇒ Object
- #config ⇒ Object
- #deliver! ⇒ Object
-
#initialize(source) ⇒ MailFakk2
constructor
A new instance of MailFakk2.
- #write_callfile ⇒ Object
Methods included from Logging
Constructor Details
#initialize(source) ⇒ MailFakk2
Returns a new instance of MailFakk2.
10 11 12 |
# File 'lib/mailfakk2.rb', line 10 def initialize(source) @fax = Facsimile.new(source) end |
Instance Attribute Details
#fax ⇒ Object (readonly)
Returns the value of attribute fax.
8 9 10 |
# File 'lib/mailfakk2.rb', line 8 def fax @fax end |
Class Method Details
.deliver!(source) ⇒ Object
4 5 6 |
# File 'lib/mailfakk2.rb', line 4 def self.deliver!(source) new(source).deliver! end |
Instance Method Details
#archive_path ⇒ Object
21 22 23 |
# File 'lib/mailfakk2.rb', line 21 def archive_path File. File.join( config.archive_path, @fax.filename) end |
#callfile_contents ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mailfakk2.rb', line 42 def callfile_contents "Channel: DAHDI/g0/\#{@fax.number}\nMaxRetries: 5\nWaitTime: 20\nContext: incoming-fax\nApplication: SendFax\nData:\#{archive_path}\nArchive: yes\n" end |
#callfile_path ⇒ Object
25 26 27 |
# File 'lib/mailfakk2.rb', line 25 def callfile_path File.join( config.outgoing_call_dir, @fax.callfile_name) end |
#config ⇒ Object
29 30 31 |
# File 'lib/mailfakk2.rb', line 29 def config @config ||= Configuration.load end |
#deliver! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/mailfakk2.rb', line 14 def deliver! log("sending fax to #{@fax.number}") @fax.write( archive_path ) write_callfile self end |
#write_callfile ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/mailfakk2.rb', line 33 def write_callfile tmp = Tempfile.new('call') tmp.puts callfile_contents tmp.close FileUtils.mkdir_p config.outgoing_call_dir FileUtils.mv tmp.path, callfile_path FileUtils.chmod 0666, callfile_path end |