Sha256: b690bfd0e586e1b39ac7a3c95eeee5a7d26d1b64739e8d85c74a56d506ebe809

Contents?: true

Size: 886 Bytes

Versions: 15

Compression:

Stored size: 886 Bytes

Contents

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

      DEFAULTS = {
        MAX_DESCRIPTION_CHARS: 500
      }


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

      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

15 entries across 15 versions & 1 rubygems

Version Path
onebox-1.5.21 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.20 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.19 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.18 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.17 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.16 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.14 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.13 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.12 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.11 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.10 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.9 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.8 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.7 lib/onebox/engine/google_play_app_onebox.rb
onebox-1.5.6 lib/onebox/engine/google_play_app_onebox.rb