Module: Txter

Defined in:
lib/txter.rb,
lib/gateway.rb,
lib/controller.rb,
lib/contactable.rb,
lib/configuration.rb,
lib/gateway_4info.rb,
lib/gateway_twilio.rb

Defined Under Namespace

Modules: Contactable, Controller Classes: Configuration, Gateway, Gateway4info, GatewayTwilio

Class Method Summary collapse

Class Method Details

.configurationObject



16
17
18
# File 'lib/configuration.rb', line 16

def configuration
  @@configuration
end

.configure(&block) ⇒ Object



20
21
22
# File 'lib/configuration.rb', line 20

def configure(&block)
  @@configuration = Configuration.new(&block)
end

.configured?Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/configuration.rb', line 11

def configured?
  return false unless configuration
  configuration.client_id && configuration.client_key
end

.confirmation_message(confirmation_code) ⇒ Object



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

def confirmation_message(confirmation_code)
  "Code: #{confirmation_code} Enter code on web to verify phone. Msg&data rates may apply. Freq set by u. T&C & support on web site. Txt HELP for help"
end

.gatewayObject



3
4
5
# File 'lib/txter.rb', line 3

def gateway
  Txter::Gateway.current
end

.generate_confirmation_codeObject



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

def generate_confirmation_code
  chars = (0..9).to_a + ('A'..'Z').to_a
  (0...6).collect { chars[Kernel.rand(chars.length)] }.join
end

.internationalize(given_number) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/txter.rb', line 22

def internationalize(given_number)
  number = numerize(given_number)
  case number.size
  when 10
    "+1#{number}"
  when 11
    "+#{number}"
  when 12
    number =~ /\+\d(11)/ ? number : nil
  else
    nil
  end
end

.log(msg) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/txter.rb', line 10

def log(msg)
  if defined?(Rails)
    Rails.logger.info msg
  else
    STDOUT.puts msg
  end
end

.modeObject



3
4
5
# File 'lib/configuration.rb', line 3

def mode
  @@mode ||= :test
end

.mode=(new_mode) ⇒ Object



7
8
9
# File 'lib/configuration.rb', line 7

def mode=(new_mode)
  @@mode = new_mode
end

.numerize(numberish) ⇒ Object



18
19
20
# File 'lib/txter.rb', line 18

def numerize(numberish)
  numberish.to_s.scan(/\d+/).join
end