Sha256: c6ca69fd32d57b6f5de2743d9f8ed483be4d371eacde4cc1b2b3dde84cebc736

Contents?: true

Size: 732 Bytes

Versions: 1

Compression:

Stored size: 732 Bytes

Contents

module Onebox
  module Engine
    class TwitterOnebox
      include Engine
      include HTML

      matches do
        http
        maybe("www.")
        domain("twitter")
        tld("com")
        anything
        has("/status/")
      end

      private

      def data
        {
          url: @url,
          tweet_text: raw.css(".tweet-text").inner_text,
          time_date: raw.css(".metadata span").inner_text,
          user: raw.css(".stream-item-header .username").inner_text,
          avatar: raw.css(".avatar")[2]["src"],
          favorites: raw.css(".stats li .request-favorited-popup").inner_text,
          retweets: raw.css(".stats li .request-retweeted-popup").inner_text
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onebox-1.1.0 lib/onebox/engine/twitter_onebox.rb