Class: TopApps::App

Inherits:
Object
  • Object
show all
Defined in:
lib/top_apps/app.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ App

Returns a new instance of App.



17
18
19
20
# File 'lib/top_apps/app.rb', line 17

def initialize(hash)
  hash.each { |attr_key, attr_value| send("#{attr_key}=", attr_value) }
  @@all << self
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



2
3
4
# File 'lib/top_apps/app.rb', line 2

def category
  @category
end

#developerObject

Returns the value of attribute developer.



2
3
4
# File 'lib/top_apps/app.rb', line 2

def developer
  @developer
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/top_apps/app.rb', line 2

def name
  @name
end

#notesObject

Returns the value of attribute notes.



2
3
4
# File 'lib/top_apps/app.rb', line 2

def notes
  @notes
end

#profile_urlObject

Returns the value of attribute profile_url.



2
3
4
# File 'lib/top_apps/app.rb', line 2

def profile_url
  @profile_url
end

#rankObject

Returns the value of attribute rank.



2
3
4
# File 'lib/top_apps/app.rb', line 2

def rank
  @rank
end

#ratingObject

Returns the value of attribute rating.



2
3
4
# File 'lib/top_apps/app.rb', line 2

def rating
  @rating
end

Class Method Details

.allObject



9
10
11
# File 'lib/top_apps/app.rb', line 9

def self.all
  @@all
end

.create_apps_from_index(index_array) ⇒ Object



5
6
7
# File 'lib/top_apps/app.rb', line 5

def self.create_apps_from_index(index_array)
  index_array.each { |index_hash| new(index_hash) }
end

.find_by_rank(rank) ⇒ Object



13
14
15
# File 'lib/top_apps/app.rb', line 13

def self.find_by_rank(rank)
  all[rank.to_i - 1]
end

Instance Method Details

#add_attributes_from_profile(profile_hash) ⇒ Object



22
23
24
# File 'lib/top_apps/app.rb', line 22

def add_attributes_from_profile(profile_hash)
  profile_hash.each { |attr_key, attr_value| send("#{attr_key}=", attr_value) }
end