Class: Twitter::DirectMessages::WelcomeMessageWrapper

Inherits:
Identity
  • Object
show all
Defined in:
lib/twitter/direct_messages/welcome_message_wrapper.rb

Instance Attribute Summary collapse

Attributes inherited from Identity

#id

Attributes inherited from Base

#attrs

Instance Method Summary collapse

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) ⇒ WelcomeMessageWrapper

Returns a new instance of WelcomeMessageWrapper.


11
12
13
14
15
16
17
18
19
20
# File 'lib/twitter/direct_messages/welcome_message_wrapper.rb', line 11

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

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

  attrs[:welcome_message] = build_welcome_message(attrs, text)
  super
end

Instance Attribute Details

#created_timestampObject (readonly)

Returns the value of attribute created_timestamp


7
8
9
# File 'lib/twitter/direct_messages/welcome_message_wrapper.rb', line 7

def created_timestamp
  @created_timestamp
end