Class: GoogleText::Message

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(options={})
  self.text = options[:text]
  self.to = options[:to].to_s.gsub(/\D/,'')
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#display_numberObject

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_timeObject

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_timeObject

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

#fromObject

Returns the value of attribute from.



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

def from
  @from
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#labelsObject

Returns the value of attribute labels.



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

def labels
  @labels
end

#read_statusObject

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_timeObject

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_timeObject

Returns the value of attribute start_time.



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

def start_time
  @start_time
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

#toObject

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(options={})
  @client ||= Client.new(options)
end

.recentObject



10
11
12
13
# File 'lib/google_text/message.rb', line 10

def self.recent
  client.
  client.get_messages
end

.unreadObject



15
16
17
# File 'lib/google_text/message.rb', line 15

def self.unread
  recent.find_all {|message| !message.read?}
end

Instance Method Details

#mark_as_readObject



30
31
32
33
34
# File 'lib/google_text/message.rb', line 30

def mark_as_read
  client.
  client.mark_as_read(id)
  return self
end

#mark_as_sentObject



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

def mark_as_sent
  @sent_status = true
end

#read?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/google_text/message.rb', line 40

def read?
  @read_status == true
end

#sendObject



23
24
25
26
27
28
# File 'lib/google_text/message.rb', line 23

def send
  client.
  client.send_message(to,text)
  mark_as_sent
  return self
end

#sent?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/google_text/message.rb', line 44

def sent?
  @sent_status == true
end

#valid?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/google_text/message.rb', line 48

def valid?
  !text.nil? && to.match(/\d{7,}/)
end