Class: HangoutsJsonParser::Conversation
- Inherits:
-
Object
- Object
- HangoutsJsonParser::Conversation
- Defined in:
- lib/hangouts_json_parser/conversation.rb
Overview
A Hangouts chat
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The chat id.
-
#messages ⇒ Array<Message>
readonly
The Messages in this chat.
-
#participants ⇒ Array<User>
readonly
The Users that are participating in this chat.
-
#type ⇒ Symbol
readonly
The chat type, :group or :private.
Class Method Summary collapse
-
.from_state(state) ⇒ Conversation
Creates a Conversation based on a conversation_state object.
Instance Method Summary collapse
-
#initialize(id, type, participants, messages) ⇒ Conversation
constructor
A new instance of Conversation.
Constructor Details
#initialize(id, type, participants, messages) ⇒ Conversation
Returns a new instance of Conversation.
13 14 15 16 17 18 |
# File 'lib/hangouts_json_parser/conversation.rb', line 13 def initialize id, type, participants, @id = id @type = type @participants = participants @messages = end |
Instance Attribute Details
#id ⇒ String (readonly)
Returns the chat id.
5 6 7 |
# File 'lib/hangouts_json_parser/conversation.rb', line 5 def id @id end |
#messages ⇒ Array<Message> (readonly)
Returns the Messages in this chat.
11 12 13 |
# File 'lib/hangouts_json_parser/conversation.rb', line 11 def @messages end |
#participants ⇒ Array<User> (readonly)
Returns the Users that are participating in this chat.
9 10 11 |
# File 'lib/hangouts_json_parser/conversation.rb', line 9 def participants @participants end |
#type ⇒ Symbol (readonly)
Returns the chat type, :group or :private.
7 8 9 |
# File 'lib/hangouts_json_parser/conversation.rb', line 7 def type @type end |
Class Method Details
.from_state(state) ⇒ Conversation
Creates a Conversation based on a conversation_state object
23 24 25 26 27 28 |
# File 'lib/hangouts_json_parser/conversation.rb', line 23 def self.from_state state Conversation.new state['conversation']['id']['id'], type_from_string(state['conversation']['type']), state['conversation']['participant_data'].map(&User.method(:from_participant_data)), state['event'].select{ |e| e["event_type"].eql? "REGULAR_CHAT_MESSAGE" }.map(&Message.method(:from_event_data)) end |