Last active
August 29, 2015 13:56
-
-
Save markjlorenz/9178034 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FaxThing | |
DEFAULT_API_KEY = "default-key".freeze | |
attr_accessor :to | |
attr_accessor :pdf | |
attr_accessor :subject | |
attr_accessor :api_key | |
def initialize opts={} | |
opts = opts.symbolize_keys | |
self.to = opts[:to] | |
self.pdf = opts[:pdf] | |
self.subject = opts[:subject] || "Default Subject" | |
self.api_key = opts[:api_key] || DEFAUlT_API_KEY | |
end | |
def send | |
fail SomeError unless self.to && self.pdf | |
# You've won a cruise! | |
end | |
def self.send_quick opts={} | |
new(opts).send | |
end | |
end | |
# Quick usage: | |
FaxThing.send_quick(to: 'number', pdf: File.read(...), subject: 'A thing I'm sending') | |
# Detail usage: | |
ft = FaxThing.new(to: 'number', pdf: somefile) | |
ft.subject = 'wanted to specify later' | |
ft.send |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment