Class: TextSpec::Data

Inherits:
Object
  • Object
show all
Extended by:
Util
Defined in:
lib/text_spec/data.rb

Class Method Summary collapse

Methods included from Util

sanitize

Class Method Details

.add_message(message) ⇒ Object



7
8
9
10
# File 'lib/text_spec/data.rb', line 7

def self.add_message message
  @@messages ||= []
  @@messages << message
end

.clear_messagesObject



12
13
14
15
# File 'lib/text_spec/data.rb', line 12

def self.clear_messages
  @@messages = []
  @@current_text_message = nil
end

.current_numberObject



25
26
27
# File 'lib/text_spec/data.rb', line 25

def self.current_number
  @@current_number
end

.current_text_messageObject



29
30
31
# File 'lib/text_spec/data.rb', line 29

def self.current_text_message
  @@current_text_message ||= nil
end

.messagesObject



17
18
19
# File 'lib/text_spec/data.rb', line 17

def self.messages
  @@messages ||= []
end

.messages_for(phone_number) ⇒ Object



38
39
40
# File 'lib/text_spec/data.rb', line 38

def self.messages_for(phone_number)
  @@messages.select {|m| m.number == sanitize(phone_number)}
end

.open_last_text_message_for(phone_number) ⇒ Object



33
34
35
36
# File 'lib/text_spec/data.rb', line 33

def self.open_last_text_message_for(phone_number)
  message = messages_for(phone_number).first
  @@current_text_message = @@messages.delete(message)
end

.set_current_number(number) ⇒ Object



21
22
23
# File 'lib/text_spec/data.rb', line 21

def self.set_current_number(number)
  @@current_number = sanitize number
end