Class: Twitter::Tweet

Inherits:
Identity show all
Includes:
Creatable, Entities
Defined in:
lib/twitter/tweet.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 = {}) ⇒ Twitter::Tweet

Initializes a new object

Parameters:

  • attrs (Hash) (defaults to: {})


36
37
38
39
# File 'lib/twitter/tweet.rb', line 36

def initialize(attrs = {})
  attrs[:text] = attrs[:full_text] if attrs[:text].nil? && !attrs[:full_text].nil?
  super
end

Instance Attribute Details

#favorite_countInteger (readonly)

Returns:

  • (Integer)


12
13
14
# File 'lib/twitter/tweet.rb', line 12

def favorite_count
  @favorite_count
end

#filter_levelString (readonly)

Returns:

  • (String)


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

def filter_level
  @filter_level
end

#in_reply_to_screen_nameString (readonly)

Returns:

  • (String)


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

def in_reply_to_screen_name
  @in_reply_to_screen_name
end

#in_reply_to_status_idInteger (readonly) Also known as: in_reply_to_tweet_id

Returns:

  • (Integer)


12
13
14
# File 'lib/twitter/tweet.rb', line 12

def in_reply_to_status_id
  @in_reply_to_status_id
end

#in_reply_to_user_idInteger (readonly)

Returns:

  • (Integer)


12
13
14
# File 'lib/twitter/tweet.rb', line 12

def in_reply_to_user_id
  @in_reply_to_user_id
end

#langString (readonly)

Returns:

  • (String)


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

def lang
  @lang
end

#quote_countInteger (readonly)

Returns:

  • (Integer)


12
13
14
# File 'lib/twitter/tweet.rb', line 12

def quote_count
  @quote_count
end

#reply_countInteger (readonly)

Returns:

  • (Integer)


12
13
14
# File 'lib/twitter/tweet.rb', line 12

def reply_count
  @reply_count
end

#retweet_countInteger (readonly)

Returns:

  • (Integer)


12
13
14
# File 'lib/twitter/tweet.rb', line 12

def retweet_count
  @retweet_count
end

#sourceString (readonly)

Returns:

  • (String)


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

def source
  @source
end

#textString (readonly)

Returns:

  • (String)


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

def text
  @text
end

Instance Method Details

#full_textString

Note:

May be > 280 characters.

Returns:

  • (String)


43
44
45
46
47
48
49
50
# File 'lib/twitter/tweet.rb', line 43

def full_text
  if retweet?
    prefix = text[/\A(RT @[a-z0-9_]{1,20}: )/i, 1]
    [prefix, retweeted_status.text].compact.join
  else
    text
  end
end

#uriAddressable::URI Also known as: url

Returns The URL to the tweet.

Returns:

  • (Addressable::URI)

    The URL to the tweet.



54
55
56
# File 'lib/twitter/tweet.rb', line 54

def uri
  Addressable::URI.parse("https://twitter.com/#{user.screen_name}/status/#{id}") if user?
end