Class: ChatUser
Instance Attribute Summary collapse
-
#discussion ⇒ Object
Returns the value of attribute discussion.
-
#friends_ids ⇒ Object
Returns the value of attribute friends_ids.
-
#uid ⇒ Object
Returns the value of attribute uid.
Class Method Summary collapse
Instance Method Summary collapse
- #clear_discussion(did) ⇒ Object
-
#initialize(attributes) ⇒ ChatUser
constructor
A new instance of ChatUser.
- #log_with_user(other_chat_user) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ ChatUser
Returns a new instance of ChatUser.
23 24 25 26 |
# File 'lib/cockatoo_http_server.rb', line 23 def initialize(attributes) @uid = attributes[:uid] @friends_ids = [] end |
Instance Attribute Details
#discussion ⇒ Object
Returns the value of attribute discussion.
17 18 19 |
# File 'lib/cockatoo_http_server.rb', line 17 def discussion @discussion end |
#friends_ids ⇒ Object
Returns the value of attribute friends_ids.
17 18 19 |
# File 'lib/cockatoo_http_server.rb', line 17 def friends_ids @friends_ids end |
#uid ⇒ Object
Returns the value of attribute uid.
17 18 19 |
# File 'lib/cockatoo_http_server.rb', line 17 def uid @uid end |
Class Method Details
.new_from_query(query) ⇒ Object
18 19 20 21 |
# File 'lib/cockatoo_http_server.rb', line 18 def self.new_from_query(query) return nil unless query.present? && query['uid'].present? new(:uid => query['uid'].first.to_i) end |
Instance Method Details
#clear_discussion(did) ⇒ Object
32 33 34 35 36 |
# File 'lib/cockatoo_http_server.rb', line 32 def clear_discussion(did) if self.discussion.present? self.discussion.log.delete_if { || ["sid"] == did || ["did"] == did } end end |
#log_with_user(other_chat_user) ⇒ Object
28 29 30 |
# File 'lib/cockatoo_http_server.rb', line 28 def log_with_user(other_chat_user) self.discussion.present? ? self.discussion.log.select { || ["type"] == "message" && (["sid"] == other_chat_user.uid || ["did"] == other_chat_user.uid) } : [] end |