Class: Chat
- Inherits:
-
Object
- Object
- Chat
- Defined in:
- lib/model/chat.rb
Instance Attribute Summary collapse
-
#chat_number ⇒ Object
Returns the value of attribute chat_number.
-
#participants ⇒ Object
Returns the value of attribute participants.
-
#updated ⇒ Object
Returns the value of attribute updated.
Class Method Summary collapse
- .ascript_chats ⇒ Object
- .fetch_all ⇒ Object
- .from_ascript_chat(chat, chat_number) ⇒ Object
- .participants_from_ascript_chat(chat) ⇒ Object
Instance Method Summary collapse
-
#initialize(chat_number, updated, participants) ⇒ Chat
constructor
A new instance of Chat.
- #to_s ⇒ Object
Constructor Details
#initialize(chat_number, updated, participants) ⇒ Chat
Returns a new instance of Chat.
7 8 9 10 11 |
# File 'lib/model/chat.rb', line 7 def initialize(chat_number, updated, participants) self.chat_number = chat_number self.updated = updated self.participants = participants end |
Instance Attribute Details
#chat_number ⇒ Object
Returns the value of attribute chat_number.
5 6 7 |
# File 'lib/model/chat.rb', line 5 def chat_number @chat_number end |
#participants ⇒ Object
Returns the value of attribute participants.
5 6 7 |
# File 'lib/model/chat.rb', line 5 def participants @participants end |
#updated ⇒ Object
Returns the value of attribute updated.
5 6 7 |
# File 'lib/model/chat.rb', line 5 def updated @updated end |
Class Method Details
.ascript_chats ⇒ Object
21 22 23 |
# File 'lib/model/chat.rb', line 21 def self.ascript_chats Appscript.app("Messages").chats.get() end |
.fetch_all ⇒ Object
17 18 19 |
# File 'lib/model/chat.rb', line 17 def self.fetch_all ascript_chats.map.with_index(1){ |chat, i| from_ascript_chat(chat, i) } end |
.from_ascript_chat(chat, chat_number) ⇒ Object
25 26 27 |
# File 'lib/model/chat.rb', line 25 def self.from_ascript_chat(chat, chat_number) new(chat_number, chat.updated.get(), participants_from_ascript_chat(chat)) end |
.participants_from_ascript_chat(chat) ⇒ Object
29 30 31 32 33 |
# File 'lib/model/chat.rb', line 29 def self.participants_from_ascript_chat(chat) chat.participants.get().map do |participant| Participant.from_ascript_participant(participant) end end |
Instance Method Details
#to_s ⇒ Object
13 14 15 |
# File 'lib/model/chat.rb', line 13 def to_s participants.map(&:name).join(", ") end |