Module: Smess

Defined in:
lib/smess.rb,
lib/smess/sms.rb,
lib/smess/utils.rb,
lib/smess/logging.rb,
lib/smess/version.rb,
lib/smess/outputs/ipx.rb,
lib/smess/outputs/auto.rb,
lib/smess/outputs/test.rb,
lib/smess/outputs/ipxus.rb,
lib/smess/outputs/mblox.rb,
lib/smess/outputs/twilio.rb,
lib/smess/outputs/http_base.rb,
lib/smess/outputs/iconectiv.rb,
lib/smess/outputs/smsglobal.rb,
lib/smess/outputs/clickatell.rb,
lib/smess/outputs/etisalatdemo.rb,
lib/smess/outputs/global_mouth.rb,
lib/smess/country_code_registry.rb,
lib/smess/outputs/card_board_fish.rb

Defined Under Namespace

Modules: Logging Classes: Auto, CardBoardFish, Clickatell, Config, Etisalatdemo, GlobalMouth, HttpBase, Iconectiv, Ipx, Ipxus, Mblox, Sms, Smsglobal, Test, Twilio

Constant Summary collapse

OUTPUTS =

Move to config?

%w{auto card_board_fish clickatell etisalatdemo global_mouth iconectiv mblox ipxus smsglobal twilio}
COUNTRY_CODES =
[1, 20, 212, 34, 46, 49, 966, 971]
VERSION =
'1.0.5'
OUTPUT_BY_COUNTRY_CODE =
{
  "0"   => :global_mouth, # default for any undefined code
  "1"   => :iconectiv,
  "1242"=> :global_mouth,
  "1246"=> :global_mouth,
  "1264"=> :global_mouth,
  "1268"=> :global_mouth,
  "1284"=> :global_mouth,
  "1345"=> :global_mouth,
  "1441"=> :global_mouth,
  "1473"=> :global_mouth,
  "1649"=> :global_mouth,
  "1664"=> :global_mouth,
  "1670"=> :global_mouth,
  "1671"=> :global_mouth,
  "1684"=> :global_mouth,
  "1758"=> :global_mouth,
  "1767"=> :global_mouth,
  "1784"=> :global_mouth,
  "1787"=> :global_mouth,
  "1809"=> :global_mouth,
  "1868"=> :global_mouth,
  "1869"=> :global_mouth,
  "1876"=> :global_mouth,
  "20"  => :global_mouth,
  "212" => :card_board_fish,
  "34"  => :global_mouth,
  "46"  => :global_mouth,
  "49"  => :global_mouth,
  "966" => :global_mouth,
  "971" => :etisalatdemo
}

Class Method Summary collapse

Class Method Details

.booleanize(value) ⇒ Object



6
7
8
# File 'lib/smess/utils.rb', line 6

def booleanize(value)
  value.to_s.downcase == "true"
end

.configObject



40
41
42
# File 'lib/smess.rb', line 40

def self.config
  @config ||=Config.new
end

.new(*args) ⇒ Object



36
37
38
# File 'lib/smess.rb', line 36

def self.new(*args)
  Sms.new(*args)
end

.separate_sms(text) ⇒ Object

returns an array of strings of <160 char lengths, split on whitespace this should be used when sending via non-concatenating providers



34
35
36
37
38
39
40
41
42
# File 'lib/smess/utils.rb', line 34

def separate_sms(text)
  return [text] unless text.sms_length > SMS_MAX_LENGTH
  result = []
  while text.sms_length > SMS_MAX_LENGTH
    part, text = text.split_at( separation_point(text) )
    result << part.strip
  end
  result << text.strip
end

.split_sms(text) ⇒ Object

returns an array of strings of gsm-compatible lengths this should be used when sending via concatenating providers



12
13
14
15
16
17
18
19
20
21
# File 'lib/smess/utils.rb', line 12

def split_sms(text)
  return [text] unless text.sms_length > 160
  result = []

  while text.sms_length > 0
    part, text = text.split_at( split_point(text) )
    result << part
  end
  result
end