Module: Twitter::Creatable

Includes:
Memoizable
Included in:
DirectMessage, DirectMessageEvent, DirectMessages::WelcomeMessage, DirectMessages::WelcomeMessageRule, List, SavedSearch, TrendResults, Tweet, User
Defined in:
lib/twitter/creatable.rb

Overview

Provides created_at functionality for Twitter objects

Instance Method Summary collapse

Instance Method Details

#created?Boolean

Check if the created_at attribute is present

Examples:

tweet.created? # => true

Returns:

  • (Boolean)


30
31
32
# File 'lib/twitter/creatable.rb', line 30

def created?
  !!@attrs[:created_at] # steep:ignore FallbackAny
end

#created_atTime

Time when the object was created on Twitter

Examples:

tweet.created_at # => 2025-01-15 12:00:00 UTC

Returns:

  • (Time)


15
16
17
18
19
20
21
# File 'lib/twitter/creatable.rb', line 15

def created_at
  time = @attrs[:created_at] # steep:ignore FallbackAny
  return if time.nil?

  time = Time.parse(time) unless time.is_a?(Time)
  time.utc
end