Class: Twitter::DirectMessageEvent

Inherits:
Identity show all
Includes:
Creatable, Entities
Defined in:
lib/twitter/direct_message_event.rb

Instance Attribute Summary collapse

Attributes inherited from Identity

#id

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods included from Entities

#entities?, #hashtags, #hashtags?, #media, #media?, #symbols, #symbols?, #uris, #uris?, #user_mentions, #user_mentions?

Methods included from Creatable

#created?, #created_at

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, display_uri_attr_reader, object_attr_reader, predicate_attr_reader, uri_attr_reader

Methods included from Utils

flat_pmap, pmap

Constructor Details

#initialize(attrs) ⇒ DirectMessageEvent

Returns a new instance of DirectMessageEvent.


14
15
16
17
18
19
20
21
22
23
# File 'lib/twitter/direct_message_event.rb', line 14

def initialize(attrs)
  attrs = read_from_response(attrs)
  text = attrs.dig(:message_create, :message_data, :text)
  urls = attrs.dig(:message_create, :message_data, :entities, :urls)

  text.gsub!(urls[0][:url], urls[0][:expanded_url]) if urls.any?

  attrs[:direct_message] = build_direct_message(attrs, text)
  super
end

Instance Attribute Details

#created_timestampObject (readonly)

Returns the value of attribute created_timestamp


10
11
12
# File 'lib/twitter/direct_message_event.rb', line 10

def created_timestamp
  @created_timestamp
end