class Faxomat::Client::Fax

Attributes

path[R]
phone[R]
title[R]

Public Class Methods

new(opts={}) click to toggle source
# File lib/faxomat/client/fax.rb, line 6
def initialize(opts={})
  @phone = opts[:phone]
  @title = opts[:title]
  @path  = opts[:path]
end

Public Instance Methods

deliver() click to toggle source
# File lib/faxomat/client/fax.rb, line 12
def deliver
  RestClient.post url, params
ensure
  file.close unless file.closed?
end

Private Instance Methods

file() click to toggle source
# File lib/faxomat/client/fax.rb, line 34
def file
  @file ||= File.new(path, 'rb')
end
params() click to toggle source
# File lib/faxomat/client/fax.rb, line 24
def params
  {
    fax: {
      phone:    phone,
      title:    title,
      document: file
    }
  }
end
url() click to toggle source
# File lib/faxomat/client/fax.rb, line 20
def url
  'http://faxomat/faxes'
end