Class: SMSnger
- Inherits:
-
Object
- Object
- SMSnger
- Defined in:
- lib/smsnger.rb
Overview
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Class Method Summary collapse
- .carrier_name(key) ⇒ Object
- .carriers ⇒ Object
- .deliver_sms(number, carrier, message, options = {}) ⇒ Object
- .get_sms_address(number, carrier) ⇒ Object
- .setup(options = {}) ⇒ Object
Class Method Details
.carrier_name(key) ⇒ Object
49 50 51 |
# File 'lib/smsnger.rb', line 49 def self.carrier_name(key) carriers[key]['name'] end |
.carriers ⇒ Object
53 54 55 |
# File 'lib/smsnger.rb', line 53 def self.carriers @@carriers.dup end |
.deliver_sms(number, carrier, message, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/smsnger.rb', line 57 def self.deliver_sms(number,carrier,,={}) raise SMSngerException.new("Cannot deliver an empty message to #{format_number(number)}") if .nil? or .empty? [:limit] ||= .length [:from] ||= @@from_address = [0..[:limit]-1] sms_email = determine_sms_email(format_number(number),carrier) case @@mail_via when :sendmail Pony.mail(:to => sms_email, :from => [:from], :body => ) when :smtp Pony.mail(:to => sms_email, :from => [:from], :body => , :via => @@mail_via, :smtp => @@smtp_settings) else raise SMSngerException.new("Unknown mail method #{@@mail_via}.") end rescue SMSngerException => exception raise exception end |
.get_sms_address(number, carrier) ⇒ Object
78 79 80 81 |
# File 'lib/smsnger.rb', line 78 def self.get_sms_address(number,carrier) number = format_number(number) determine_sms_email(number,carrier) end |
.setup(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/smsnger.rb', line 26 def self.setup( = {}) = { :config => File.join(File.dirname(__FILE__),"carriers.yml"), :from => "[email protected]", :mail_via => :sendmail } .merge!() @@mail_via ||= [:mail_via] raise SMSngerExceptions.new("You must specify a :from address setting in SMSnger.setup!") unless .has_key?(:from) @@from_address = [:from] if @@mail_via == :smtp raise SMSngerExceptions.new("You must specify the :smtp settings in SMSnger.setup!") unless .has_key?(:smtp) smtp_config([:smtp]) end load_carriers([:config]) return end |