Class: EFreeSMS::SMS

Inherits:
Object
  • Object
show all
Defined in:
lib/efreesms.rb

Class Method Summary collapse

Class Method Details

.send(user, country, number, text) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/efreesms.rb', line 49

def send (user, country, number, text)
  $stderr.sync = true
  txts = text.split(//).each_slice(120 - user.size - 2).map(&:join)

  txts.each_with_index {|txt, i|
    begin
      $stderr.print "\rsending #{i + 1}/#{txts.size}"
      real_send(country, number, ("%s: %s" % [user, txt]))
    rescue Exception => e
      $stderr.puts e
      retry
    end
  }

  $stderr.puts "\nSent."
end