forked from adammck/rubygsm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved GsmModem to Gsm::Modem, and started passing around message
objects, rather than strings. still a bit shaky
- Loading branch information
Showing
7 changed files
with
140 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# vim: noet | ||
#++ | ||
|
||
class GsmModem | ||
module Gsm | ||
class Error < StandardError | ||
ERRORS = { | ||
"CME" => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env ruby | ||
# vim: noet | ||
|
||
module Gsm | ||
class Incoming | ||
attr_reader :device, :sender, :sent, :received, :text | ||
|
||
def initialize(device, sender, sent, text) | ||
|
||
# move all arguments into read-only | ||
# attributes. ugly, but Struct only | ||
# supports read/write attrs | ||
@device = device | ||
@sender = sender | ||
@sent = sent | ||
@text = text | ||
|
||
# assume that the message was | ||
# received right now, since we | ||
# don't have an incoming buffer | ||
@received = Time.now | ||
end | ||
|
||
def to_a | ||
[@device, @sender, @sent, @text] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env ruby | ||
# vim: noet | ||
|
||
module Gsm | ||
class Outgoing | ||
attr_accessor :recipient, :text | ||
attr_reader :device, :sent | ||
|
||
def initialize(device, recipient=nil, text=nil) | ||
|
||
# check that the device is | ||
#raise ArgumentError, "Invalid device"\ | ||
# unless device.respond_to?(:send_sms) | ||
|
||
# init the instance vars | ||
@recipient = recipient | ||
@device = device | ||
@text = text | ||
end | ||
|
||
def send! | ||
@device.send_sms(self) | ||
@sent = Time.now | ||
|
||
# once sent, allow no | ||
# more modifications | ||
freeze | ||
end | ||
end | ||
end |