Class: GoogleText::Message
- Inherits:
-
Object
- Object
- GoogleText::Message
- Defined in:
- lib/google_text/message.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#display_number ⇒ Object
Returns the value of attribute display_number.
-
#display_start_date_time ⇒ Object
Returns the value of attribute display_start_date_time.
-
#display_start_time ⇒ Object
Returns the value of attribute display_start_time.
-
#from ⇒ Object
Returns the value of attribute from.
-
#id ⇒ Object
Returns the value of attribute id.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#read_status ⇒ Object
Returns the value of attribute read_status.
-
#relative_start_time ⇒ Object
Returns the value of attribute relative_start_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#text ⇒ Object
Returns the value of attribute text.
-
#to ⇒ Object
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Message
constructor
A new instance of Message.
- #mark_as_read ⇒ Object
- #mark_as_sent ⇒ Object
- #read? ⇒ Boolean
- #send ⇒ Object
- #sent? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Message
Returns a new instance of Message.
5 6 7 8 |
# File 'lib/google_text/message.rb', line 5 def initialize(={}) self.text = [:text] self.to = [:to].to_s.gsub(/\D/,'') end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def client @client end |
#display_number ⇒ Object
Returns the value of attribute display_number.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def display_number @display_number end |
#display_start_date_time ⇒ Object
Returns the value of attribute display_start_date_time.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def display_start_date_time @display_start_date_time end |
#display_start_time ⇒ Object
Returns the value of attribute display_start_time.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def display_start_time @display_start_time end |
#from ⇒ Object
Returns the value of attribute from.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def from @from end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def id @id end |
#labels ⇒ Object
Returns the value of attribute labels.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def labels @labels end |
#read_status ⇒ Object
Returns the value of attribute read_status.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def read_status @read_status end |
#relative_start_time ⇒ Object
Returns the value of attribute relative_start_time.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def relative_start_time @relative_start_time end |
#start_time ⇒ Object
Returns the value of attribute start_time.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def start_time @start_time end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def text @text end |
#to ⇒ Object
Returns the value of attribute to.
3 4 5 |
# File 'lib/google_text/message.rb', line 3 def to @to end |
Class Method Details
.client(options = {}) ⇒ Object
19 20 21 |
# File 'lib/google_text/message.rb', line 19 def self.client(={}) @client ||= Client.new() end |
.recent ⇒ Object
10 11 12 13 |
# File 'lib/google_text/message.rb', line 10 def self.recent client.login client. end |
.unread ⇒ Object
15 16 17 |
# File 'lib/google_text/message.rb', line 15 def self.unread recent.find_all {|| !.read?} end |
Instance Method Details
#mark_as_read ⇒ Object
30 31 32 33 34 |
# File 'lib/google_text/message.rb', line 30 def mark_as_read client.login client.mark_as_read(id) return self end |
#mark_as_sent ⇒ Object
36 37 38 |
# File 'lib/google_text/message.rb', line 36 def mark_as_sent @sent_status = true end |
#read? ⇒ Boolean
40 41 42 |
# File 'lib/google_text/message.rb', line 40 def read? @read_status == true end |
#send ⇒ Object
23 24 25 26 27 28 |
# File 'lib/google_text/message.rb', line 23 def send client.login client.(to,text) mark_as_sent return self end |
#sent? ⇒ Boolean
44 45 46 |
# File 'lib/google_text/message.rb', line 44 def sent? @sent_status == true end |
#valid? ⇒ Boolean
48 49 50 |
# File 'lib/google_text/message.rb', line 48 def valid? !text.nil? && to.match(/\d{7,}/) end |