Class: ArticleJSON::Utils::OEmbedResolver::Tweet

Inherits:
Base
  • Object
show all
Defined in:
lib/article_json/utils/o_embed_resolver/tweet.rb

Instance Method Summary collapse

Methods inherited from Base

build, #initialize, #oembed_data, resolver_by_embed_type, #unavailable_message

Constructor Details

This class inherits a constructor from ArticleJSON::Utils::OEmbedResolver::Base

Instance Method Details

#nameString

Human readable name of the resolver

Returns:

  • (String)


7
8
9
# File 'lib/article_json/utils/o_embed_resolver/tweet.rb', line 7

def name
  'Tweet'
end

#oembed_urlString

The URL for the oembed API call

Returns:

  • (String)


13
14
15
16
# File 'lib/article_json/utils/o_embed_resolver/tweet.rb', line 13

def oembed_url
  'https://api.twitter.com/1/statuses/oembed.json?align=center' \
    "&url=#{source_url}"
end

#source_urlString

The URL of the tweet

Returns:

  • (String)


20
21
22
23
# File 'lib/article_json/utils/o_embed_resolver/tweet.rb', line 20

def source_url
  handle, tweet_id = @element.embed_id.split('/', 2)
  "https://twitter.com/#{handle}/status/#{tweet_id}"
end