Class: Panchira::TwitterResolver
- Defined in:
- lib/panchira/resolvers/twitter_resolver.rb
Constant Summary collapse
- URL_REGEXP =
/twitter.com\/(\w+)\/status\/(\d+)/.freeze
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(url, options = nil) ⇒ TwitterResolver
constructor
A new instance of TwitterResolver.
Methods inherited from Resolver
Constructor Details
#initialize(url, options = nil) ⇒ TwitterResolver
Returns a new instance of TwitterResolver.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/panchira/resolvers/twitter_resolver.rb', line 9 def initialize(url, = nil) super(url, ) @screen_name = @url.slice(URL_REGEXP, 1) @id = @url.slice(URL_REGEXP, 2) @bearer_token = &.dig(:twitter, :bearer_token) @author = nil @response = nil end |
Instance Method Details
#fetch ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/panchira/resolvers/twitter_resolver.rb', line 20 def fetch return super unless @bearer_token @response = fetch_api if @bearer_token result = PanchiraResult.new result.canonical_url = parse_canonical_url result.title = parse_title result.description = parse_description result.image = parse_image result. = result. = result.resolver = parse_resolver result end |