Class: DailyTrending::App
- Inherits:
-
Object
- Object
- DailyTrending::App
- Defined in:
- lib/daily_trending/app.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#app_url ⇒ Object
Returns the value of attribute app_url.
-
#con_rating ⇒ Object
Returns the value of attribute con_rating.
-
#description ⇒ Object
Returns the value of attribute description.
-
#dev ⇒ Object
Returns the value of attribute dev.
-
#dev_url ⇒ Object
Returns the value of attribute dev_url.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#price ⇒ Object
Returns the value of attribute price.
-
#rate_cnt ⇒ Object
Returns the value of attribute rate_cnt.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .all ⇒ Object
-
.new_from_index(a) ⇒ Object
def self.make_apps.
Instance Method Summary collapse
Instance Attribute Details
#app_url ⇒ Object
Returns the value of attribute app_url.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def app_url @app_url end |
#con_rating ⇒ Object
Returns the value of attribute con_rating.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def @con_rating end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def description @description end |
#dev ⇒ Object
Returns the value of attribute dev.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def dev @dev end |
#dev_url ⇒ Object
Returns the value of attribute dev_url.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def dev_url @dev_url end |
#genre ⇒ Object
Returns the value of attribute genre.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def genre @genre end |
#price ⇒ Object
Returns the value of attribute price.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def price @price end |
#rate_cnt ⇒ Object
Returns the value of attribute rate_cnt.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def rate_cnt @rate_cnt end |
#rating ⇒ Object
Returns the value of attribute rating.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def @rating end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/daily_trending/app.rb', line 2 def title @title end |
Class Method Details
.all ⇒ Object
34 35 36 |
# File 'lib/daily_trending/app.rb', line 34 def self.all @@all end |
.new_from_index(a) ⇒ Object
def self.make_apps
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/daily_trending/app.rb', line 13 def self.new_from_index(a) app = self.new app.title = a.css('a.title').attribute('title').value app.dev = a.css('a.subtitle').attribute('title').value app.dev_url = ("https://play.google.com" + a.css('a.subtitle').attribute('href').value) app.app_url = ("https://play.google.com" + a.css('a.title').attribute('href').value) app. = a.css('div.tiny-star').attribute('aria-label').value.strip.slice(/\d.\S/)<<"/5 Stars" app.price = a.at_css('span.display-price').text app.exist? ? all.freeze : app.save end |
Instance Method Details
#exist? ⇒ Boolean
25 26 27 |
# File 'lib/daily_trending/app.rb', line 25 def exist? self.class.all.any?{|ap| ap.title == self.title} end |
#make_app(xml_info) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/daily_trending/app.rb', line 39 def make_app(xml_info) page = xml_info self.genre = page.css('a.document-subtitle.category').text self.description = page.css('div.show-more-content.text-body').text self. = page.css('span.document-subtitle.content-rating-title').text self.rate_cnt = page.css('span.rating-count').text end |
#save ⇒ Object
30 31 32 |
# File 'lib/daily_trending/app.rb', line 30 def save @@all << self end |