Class: Applist::Apps
- Inherits:
-
Object
- Object
- Applist::Apps
- Defined in:
- lib/applist/apps.rb
Instance Attribute Summary collapse
-
#avg_rating ⇒ Object
Returns the value of attribute avg_rating.
-
#category ⇒ Object
Returns the value of attribute category.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Attribute Details
#avg_rating ⇒ Object
Returns the value of attribute avg_rating.
2 3 4 |
# File 'lib/applist/apps.rb', line 2 def @avg_rating end |
#category ⇒ Object
Returns the value of attribute category.
2 3 4 |
# File 'lib/applist/apps.rb', line 2 def category @category end |
#desc ⇒ Object
Returns the value of attribute desc.
2 3 4 |
# File 'lib/applist/apps.rb', line 2 def desc @desc end |
#link ⇒ Object
Returns the value of attribute link.
2 3 4 |
# File 'lib/applist/apps.rb', line 2 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/applist/apps.rb', line 2 def name @name end |
Class Method Details
.popular ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/applist/apps.rb', line 4 def self.popular app_page = Nokogiri::HTML(open("https://www.apple.com/itunes/charts/free-apps/")) apps = [] app_page.css("div.section-content li").each do |app| @app_obj = { name: '', category: '', link: '', desc: '', avg_rating: '' } @app_obj[:name] = [app.css("h3 a").text] @app_obj[:category] = [app.css("h4 a").text] @app_obj[:link] = [app.css("a").attribute("href").value] doc = Nokogiri::HTML(open(@app_obj[:link][0], 'User-Agent' => 'firefox')) @app_obj[:desc] = doc.css(".section__description").text @app_obj[:avg_rating] = doc.css(".we-customer-ratings__averages__display").text apps << @app_obj end apps end |