Sha256: 7f54ce2ab26416e683a0737001b7c4bf277b7da058bc2dc84fca3f5f16839f93

Contents?: true

Size: 901 Bytes

Versions: 2

Compression:

Stored size: 901 Bytes

Contents

module Onebox
  module Engine
    class GooglePlayAppOnebox
      include Engine
      include LayoutSupport
      include HTML

      DEFAULTS = {
        MAX_DESCRIPTION_CHARS: 500
      }


      matches_regexp Regexp.new("^https?://play\\.(?:(?:\\w)+\\.)?(google)\\.com(?:/)?/store/apps/")
      always_https

      private

      def data
        result = {
          link: link,
          title: raw.css(".document-title div").inner_text,
          developer: raw.css(".document-subtitle.primary").inner_text,
          image: raw.css(".cover-image").first["src"],
          description: raw.css(".text-body div").inner_text[0..DEFAULTS[:MAX_DESCRIPTION_CHARS]].chop + "...",
          price: raw.css(".price.buy meta[itemprop=price]").first["content"]
        }
        if result[:price].to_i <= 0 then
            result[:price] = "Free"
        end
        result
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
onebox-1.5.23 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.22 lib/onebox/engine/google_play_app_onebox.rb