Class: AppStoreInfo::App

Inherits:
Object
  • Object
show all
Includes:
JSONAccessors
Defined in:
lib/appstore_info/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JSONAccessors

included, #read_json_accessors

Constructor Details

#initialize(json) ⇒ App

Returns a new instance of App.



18
19
20
21
22
23
24
# File 'lib/appstore_info/app.rb', line 18

def initialize(json)
  read_json_accessors(json)

  @artwork = json['artworkUrl512'] || json['artworkUrl100']

  @current_version = read_current_version(json)
end

Instance Attribute Details

#current_versionObject (readonly)

Returns the value of attribute current_version.



8
9
10
# File 'lib/appstore_info/app.rb', line 8

def current_version
  @current_version
end

Instance Method Details

#genre_namesObject



30
31
32
# File 'lib/appstore_info/app.rb', line 30

def genre_names
  @genre_ids.map { |genre| AppStoreInfo::GENRES[genre.to_i] }
end

#store_icon_urlObject



34
35
36
37
38
# File 'lib/appstore_info/app.rb', line 34

def store_icon_url
  return unless @artwork

  @artwork =~ /\.(png|jpg|gif)\z/ ? @artwork : nil
end

#universal?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/appstore_info/app.rb', line 26

def universal?
  @features.include?('iosUniversal')
end