utel 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -1
- data/balance.rb +0 -2
- data/lib/utel.rb +1 -0
- data/lib/utel/operator.rb +1 -0
- data/lib/utel/sms.rb +34 -0
- data/lib/utel/version.rb +1 -1
- metadata +4 -3
data/README.md
CHANGED
@@ -18,12 +18,25 @@ Utel::Balance
|
|
18
18
|
Utel::Balance.vas
|
19
19
|
=> "Internet:3G 1572602.0Kb,Universalnyi 144140.0Kb,Nat.rouming 0.0Kb;0.0SMS po Ukraini;0v mezhah Ukrainy;0na inshi mobilni Ukrainy"
|
20
20
|
|
21
|
-
|
21
|
+
Текущий оператор
|
22
|
+
----------------
|
23
|
+
|
24
|
+
Utel::Operator.name
|
25
|
+
=> "UTEL3G�"
|
26
|
+
|
27
|
+
Отправить SMS
|
28
|
+
-------------
|
29
|
+
|
30
|
+
Utel::SMS.send('0917776655', 'Hello, world!')
|
31
|
+
|
32
|
+
|
33
|
+
Узнать баланс и текущего оператора кастомным скриптом
|
22
34
|
---------------------------
|
23
35
|
|
24
36
|
$ ruby balance.rb
|
25
37
|
Vash balans:zagal'nyi 46,06; paketnyi 0,00; dodatkovyi 0,00 hrn.Perevirka dodatkovykh poslug *121#
|
26
38
|
Internet:3G 1572602.0Kb,Universalnyi 144140.0Kb,Nat.rouming 0.0Kb;0.0SMS po Ukraini;0v mezhah Ukrainy;0na inshi mobilni Ukrainy
|
39
|
+
UTEL3G�
|
27
40
|
|
28
41
|
TODO
|
29
42
|
----
|
data/balance.rb
CHANGED
data/lib/utel.rb
CHANGED
data/lib/utel/operator.rb
CHANGED
data/lib/utel/sms.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Utel
|
2
|
+
class SMS
|
3
|
+
def self.send *args
|
4
|
+
new.send(*args)
|
5
|
+
end
|
6
|
+
|
7
|
+
def send number, message
|
8
|
+
out = ''
|
9
|
+
File.open(Utel::DEVICE, "w+") do |f|
|
10
|
+
f.write "AT+CMGF=1\r\n"
|
11
|
+
f.write "AT+CMGS=\"#{number}\"\r\n"
|
12
|
+
f.write "#{message}\x1A"
|
13
|
+
|
14
|
+
while(s = f.gets) do
|
15
|
+
if s.slice(0, 2) == "OK"
|
16
|
+
out << s
|
17
|
+
break if out.scan(/OK/).count == 2
|
18
|
+
else
|
19
|
+
if (s.slice(0, 10) == "+CMS ERROR")
|
20
|
+
out << s
|
21
|
+
break
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
parse_response(out)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def parse_response output
|
31
|
+
output =~ /ERROR/ ? false : true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/utel/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eugene Russkikh
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/utel/balance.rb
|
39
39
|
- lib/utel/operator.rb
|
40
40
|
- lib/utel/pdu.rb
|
41
|
+
- lib/utel/sms.rb
|
41
42
|
- lib/utel/version.rb
|
42
43
|
- utel.gemspec
|
43
44
|
has_rdoc: true
|