Class: AppStoreLookup::App
- Inherits:
-
Object
- Object
- AppStoreLookup::App
- Defined in:
- lib/app_store_lookup.rb
Instance Attribute Summary collapse
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#artwork ⇒ Object
readonly
Returns the value of attribute artwork.
-
#bundle_id ⇒ Object
readonly
Returns the value of attribute bundle_id.
-
#censored_name ⇒ Object
readonly
Returns the value of attribute censored_name.
-
#content_advisory_rating ⇒ Object
readonly
Returns the value of attribute content_advisory_rating.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#current_version_rating ⇒ Object
readonly
Returns the value of attribute current_version_rating.
-
#current_version_release_date ⇒ Object
readonly
Returns the value of attribute current_version_release_date.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#file_size ⇒ Object
readonly
Returns the value of attribute file_size.
-
#genres ⇒ Object
readonly
Returns the value of attribute genres.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_game_center_enabled ⇒ Object
readonly
Returns the value of attribute is_game_center_enabled.
-
#is_vpp_device_based_licensing_enabled ⇒ Object
readonly
Returns the value of attribute is_vpp_device_based_licensing_enabled.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
-
#minimum_os_version ⇒ Object
readonly
Returns the value of attribute minimum_os_version.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#primary_genre ⇒ Object
readonly
Returns the value of attribute primary_genre.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#release_date ⇒ Object
readonly
Returns the value of attribute release_date.
-
#screenshots ⇒ Object
readonly
Returns the value of attribute screenshots.
-
#seller ⇒ Object
readonly
Returns the value of attribute seller.
-
#supported_devices ⇒ Object
readonly
Returns the value of attribute supported_devices.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(attributes = {}) ⇒ App
Returns a new instance of App.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/app_store_lookup.rb', line 8 def initialize(attributes = {}) require 'date' @id = attributes['trackId'].to_i @name = attributes['trackName'] @censored_name = attributes['trackCensoredName'] @kind = attributes['kind'] @release_date = DateTime.parse(attributes['releaseDate']) @primary_genre = AppStoreLookup::AppGenre.new(:name => attributes['primaryGenreName'], :id => attributes['primaryGenreId']) @genres = attributes['genres'].each_with_index.map {|genre,i| AppStoreLookup::AppGenre.new(:name => genre, :id => attributes['genreIds'][i])} @price = attributes['price'].to_f @currency = attributes['currency'] @version = attributes['version'] @current_version_release_date = DateTime.parse(attributes['currentVersionReleaseDate']) @artist = AppStoreLookup::AppArtist.new(:name => attributes['artistName'], :id => attributes['artistId'], :url => attributes['artistViewUrl']) @bundle_id = attributes['bundleId'] @minimum_os_version = attributes['minimum_os_version'] @description = attributes['description'] @is_vpp_device_based_licensing_enabled = attributes['isVppDeviceBasedLicensingEnabled'] @is_game_center_enabled = attributes['is_game_center_enabled'] @rating = AppStoreLookup::AppRating.new(:count => attributes['userRatingCount'], :rating => attributes['averageUserRating']) @current_version_rating = AppStoreLookup::AppRating.new(:count => attributes['userRatingCountForCurrentVersion'], :rating => attributes['averageUserRatingForCurrentVersion']) @seller = AppStoreLookup::AppSeller.new(:name => attributes['sellerName'], :url => attributes['sellerUrl']) @file_size = attributes['fileSizeBytes'].to_i @languages = attributes['languageCodesISO2A'].map {|l| AppStoreLookup::AppLanguage.new(:code => l)} @content_advisory_rating = attributes['contentAdvisoryRating'] @url = attributes['trackViewUrl'] @supported_devices = attributes['supportedDevices'].map {|sd| AppStoreLookup::AppSupportedDevices.new(:name => sd)} @artwork = { :a60 => AppStoreLookup::AppImage.new(:url => attributes['artworkUrl60']), :a100 => AppStoreLookup::AppImage.new(:url => attributes['artworkUrl100']), :a512 => AppStoreLookup::AppImage.new(:url => attributes['artworkUrl512'])} @screenshots = {:iphone => attributes['screenshotUrls'].map {|s| AppStoreLookup::AppImage.new(:url => s)}, :ipad => attributes['ipadScreenshotUrls'].map {|s| AppStoreLookup::AppImage.new(:url => s)}, :apple_tv => attributes['appletvScreenshotUrls'].map {|s| AppStoreLookup::AppImage.new(:url => s)}} end |
Instance Attribute Details
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def artist @artist end |
#artwork ⇒ Object (readonly)
Returns the value of attribute artwork.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def artwork @artwork end |
#bundle_id ⇒ Object (readonly)
Returns the value of attribute bundle_id.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def bundle_id @bundle_id end |
#censored_name ⇒ Object (readonly)
Returns the value of attribute censored_name.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def censored_name @censored_name end |
#content_advisory_rating ⇒ Object (readonly)
Returns the value of attribute content_advisory_rating.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def @content_advisory_rating end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def currency @currency end |
#current_version_rating ⇒ Object (readonly)
Returns the value of attribute current_version_rating.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def @current_version_rating end |
#current_version_release_date ⇒ Object (readonly)
Returns the value of attribute current_version_release_date.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def current_version_release_date @current_version_release_date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def description @description end |
#file_size ⇒ Object (readonly)
Returns the value of attribute file_size.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def file_size @file_size end |
#genres ⇒ Object (readonly)
Returns the value of attribute genres.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def genres @genres end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def id @id end |
#is_game_center_enabled ⇒ Object (readonly)
Returns the value of attribute is_game_center_enabled.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def is_game_center_enabled @is_game_center_enabled end |
#is_vpp_device_based_licensing_enabled ⇒ Object (readonly)
Returns the value of attribute is_vpp_device_based_licensing_enabled.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def is_vpp_device_based_licensing_enabled @is_vpp_device_based_licensing_enabled end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def kind @kind end |
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def languages @languages end |
#minimum_os_version ⇒ Object (readonly)
Returns the value of attribute minimum_os_version.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def minimum_os_version @minimum_os_version end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def name @name end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def price @price end |
#primary_genre ⇒ Object (readonly)
Returns the value of attribute primary_genre.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def primary_genre @primary_genre end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def @rating end |
#release_date ⇒ Object (readonly)
Returns the value of attribute release_date.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def release_date @release_date end |
#screenshots ⇒ Object (readonly)
Returns the value of attribute screenshots.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def screenshots @screenshots end |
#seller ⇒ Object (readonly)
Returns the value of attribute seller.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def seller @seller end |
#supported_devices ⇒ Object (readonly)
Returns the value of attribute supported_devices.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def supported_devices @supported_devices end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def url @url end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/app_store_lookup.rb', line 5 def version @version end |
Class Method Details
.find_by_bundle_id(bundle_id) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/app_store_lookup.rb', line 39 def self.find_by_bundle_id(bundle_id) require 'net/http' require 'uri' require 'json' listing = JSON.parse(Net::HTTP.get(URI.parse("https://itunes.apple.com/lookup?bundleId="+bundle_id)))['results'] unless listing.empty? AppStoreLookup::App.new(listing[0]) else end end |