Sha256: d4cde6ce8eaf2092a92839ee7440c7ae1c1d2e7f24a2b0f31786bc251596df68

Contents?: true

Size: 547 Bytes

Versions: 3

Compression:

Stored size: 547 Bytes

Contents

require 'apprank/app'

module Apprank
  class Rank

    attr_accessor :apps, :link, :updated

    def initialize(text)
      begin
        data = JSON.load(text)
        apps_data = data["feed"]["entry"]
        @link = data["feed"]["link"].last["attributes"]["href"]
        @apps = apps_data.map do |app|
            Apprank::App.new(app)
          end
        @updated = Time.parse(data["feed"]["updated"]["label"])
      rescue
        raise BadJsonData
      end
    end

    def country
      self.link[/cc=(\w*)/][3..-1]
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
apprank-1.0.1 lib/apprank/rank.rb
apprank-1.0.0 lib/apprank/rank.rb
apprank-0.0.1 lib/apprank/rank.rb