Class: Apprank::Rank
- Inherits:
-
Object
- Object
- Apprank::Rank
- Defined in:
- lib/apprank/rank.rb
Instance Attribute Summary collapse
-
#apps ⇒ Object
Returns the value of attribute apps.
-
#link ⇒ Object
Returns the value of attribute link.
-
#updated ⇒ Object
Returns the value of attribute updated.
Instance Method Summary collapse
- #country ⇒ Object
-
#initialize(text) ⇒ Rank
constructor
A new instance of Rank.
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
#apps ⇒ Object
Returns the value of attribute apps.
6 7 8 |
# File 'lib/apprank/rank.rb', line 6 def apps @apps end |
#link ⇒ Object
Returns the value of attribute link.
6 7 8 |
# File 'lib/apprank/rank.rb', line 6 def link @link end |
#updated ⇒ Object
Returns the value of attribute updated.
6 7 8 |
# File 'lib/apprank/rank.rb', line 6 def updated @updated end |
Instance Method Details
#country ⇒ Object
22 23 24 |
# File 'lib/apprank/rank.rb', line 22 def country self.link[/cc=(\w*)/][3..-1] end |