lib/mblox/sms.rb in mblox-0.4.2 vs lib/mblox/sms.rb in mblox-0.5.0
- old
+ new
@@ -9,18 +9,19 @@
class Sms
class InvalidPhoneNumberError < ::ArgumentError; end
class InvalidMessageError < ::ArgumentError; end
class BatchIdOutOfRangeError < ::ArgumentError; end
class InvalidSenderIdError < ::ArgumentError; end
+ class MessageTooLongError < ::ArgumentError; end
MAX_LENGTH = 160
MAX_SECTION_LENGTH = MAX_LENGTH - "(MSG XXX/XXX): ".size
LEGAL_CHARACTERS = "~\`!\"#\$\%&'\(\)*+,-.\/:;<=>?@_£¤¥§¿i¡ÄÅÆÇÉÑÖØÜßâáäåæèéìñòöøóùüú\n\r\tí "
ILLEGAL_CHARACTERS = /([^a-zA-Z0-9#{LEGAL_CHARACTERS}\\])/
attr_reader :phone, :message
ON_MESSAGE_TOO_LONG_HANDLER = {
- :raise_error => Proc.new { raise InvalidMessageError, "Message cannot be longer than #{MAX_LENGTH} characters" },
+ :raise_error => Proc.new { raise MessageTooLongError, "Message cannot be longer than #{MAX_LENGTH} characters" },
:truncate => Proc.new { |message| Mblox.log "Truncating message due to length. Message was: \"#{message}\" but will now be \"#{message = message[0,MAX_LENGTH]}\""; [message] },
:split => Proc.new { |message| split_message(message) }
}
def initialize(phone, message, batch_id=nil)