Class: Apprank::Rank

Inherits:
Object
  • Object
show all
Defined in:
lib/apprank/rank.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Rank

Returns a new instance of Rank.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/apprank/rank.rb', line 8

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

Instance Attribute Details

#appsObject

Returns the value of attribute apps.



6
7
8
# File 'lib/apprank/rank.rb', line 6

def apps
  @apps
end

Returns the value of attribute link.



6
7
8
# File 'lib/apprank/rank.rb', line 6

def link
  @link
end

#updatedObject

Returns the value of attribute updated.



6
7
8
# File 'lib/apprank/rank.rb', line 6

def updated
  @updated
end

Instance Method Details

#countryObject



22
23
24
# File 'lib/apprank/rank.rb', line 22

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