class Apprank::App
Attributes
artist[RW]
bundle_id[RW]
category[RW]
content_type[RW]
developer[RW]
icon_urls[RW]
itunes_id[RW]
itunes_url[RW]
link[RW]
name[RW]
preview[RW]
price[RW]
release_date[RW]
rights[RW]
summary[RW]
title[RW]
Public Class Methods
new(hash)
click to toggle source
# File lib/apprank/app.rb, line 9 def initialize(hash) @name = App.get_label(hash, "im:name") @icon_urls = App.get_icon_urls(hash["im:image"]) @summary = App.get_label(hash, "summary") @price = { amount: App.get_attributes(hash, "im:price")["amount"].to_f, currency: App.get_attributes(hash, "im:price")["currency"], } @content_type = App.get_attributes(hash, "im:contentType")["term"] @rights = App.get_label(hash, "rights") @title = App.get_label(hash, "title") @link = App.get_attributes(hash, "link")["href"] @itunes_url = App.get_label(hash, "id") @itunes_id = App.get_attributes(hash, "id")['im:id'] @bundle_id = App.get_attributes(hash, "id")['im:bundleId'] @artist = { :name => App.get_label(hash, "im:artist"), :url => App.get_attributes(hash, "im:artist")["href"], } category = App.get_attributes(hash, "category") @category = { :name => category["term"], :url => category["scheme"], } @release_date = Time.parse(App.get_label(hash, "im:releaseDate")) end
Private Class Methods
get_attributes(hash, field)
click to toggle source
# File lib/apprank/app.rb, line 53 def self.get_attributes(hash, field) hash[field]["attributes"] end
get_icon_urls(images)
click to toggle source
# File lib/apprank/app.rb, line 61 def self.get_icon_urls(images) icon_urls = {} images.each do |image| height = if image["attributes"]["height"] == '53' :small elsif image["attributes"]["height"] == '75' :medium else :large end icon_urls[height] = image["label"] end icon_urls end
get_label(hash, field)
click to toggle source
# File lib/apprank/app.rb, line 57 def self.get_label(hash, field) hash[field]["label"] end
Public Instance Methods
category_id()
click to toggle source
# File lib/apprank/app.rb, line 43 def category_id self.category[:url].split(/\//).last.split(/\?/).first.gsub(/[^\d]/, '') end
is_free?()
click to toggle source
# File lib/apprank/app.rb, line 47 def is_free? self.price[:amount].zero? end