Class: PlayResult
- Inherits:
-
Object
- Object
- PlayResult
- Defined in:
- lib/google-play-class.rb
Instance Attribute Summary collapse
-
#actors ⇒ Object
Returns the value of attribute actors.
-
#contentrating ⇒ Object
Returns the value of attribute contentrating.
-
#description ⇒ Object
Returns the value of attribute description.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lengthtime ⇒ Object
Returns the value of attribute lengthtime.
-
#price ⇒ Object
Returns the value of attribute price.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#related ⇒ Object
Returns the value of attribute related.
-
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #fillPlayData(id, type, title) ⇒ Object
- #get_actors(doc) ⇒ Object
- #get_contentrating(doc) ⇒ Object
- #get_description(doc) ⇒ Object
- #get_genre(doc) ⇒ Object
- #get_lengthtime(doc) ⇒ Object
- #get_price(doc) ⇒ Object
- #get_rating(doc) ⇒ Object
- #get_related(doc) ⇒ Object
- #get_thumbnail(doc) ⇒ Object
- #get_title(doc) ⇒ Object
-
#initialize(id, type, title) ⇒ PlayResult
constructor
A new instance of PlayResult.
Constructor Details
#initialize(id, type, title) ⇒ PlayResult
Returns a new instance of PlayResult.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/google-play-class.rb', line 7 def initialize(id,type,title) @id=id @type=type @title=title @price="" @rating="" @description="" @thumbnail="" @actors=Array.new @lengthtime="" @contentrating="" @genre="" @related=Array.new fillPlayData(id,type,title) end |
Instance Attribute Details
#actors ⇒ Object
Returns the value of attribute actors.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def actors @actors end |
#contentrating ⇒ Object
Returns the value of attribute contentrating.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def @contentrating end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def description @description end |
#genre ⇒ Object
Returns the value of attribute genre.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def genre @genre end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def id @id end |
#lengthtime ⇒ Object
Returns the value of attribute lengthtime.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def lengthtime @lengthtime end |
#price ⇒ Object
Returns the value of attribute price.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def price @price end |
#rating ⇒ Object
Returns the value of attribute rating.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def @rating end |
#related ⇒ Object
Returns the value of attribute related.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def @related end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def thumbnail @thumbnail end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/google-play-class.rb', line 5 def type @type end |
Instance Method Details
#fillPlayData(id, type, title) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/google-play-class.rb', line 23 def fillPlayData(id,type,title) doc = Nokogiri::HTML(open("https://play.google.com/store/#{type}/details?id=#{id}")) get_price(doc) (doc) get_description(doc) get_thumbnail(doc) get_actors(doc) get_lengthtime(doc) (doc) get_genre(doc) (doc) end |
#get_actors(doc) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/google-play-class.rb', line 64 def get_actors(doc) if doc.css('td.credit-cell span[itemprop=actors] a span').length != 0 doc.css('td.credit-cell span[itemprop=actors] a span').each{ |value| @actors << value.text.to_s } end end |
#get_contentrating(doc) ⇒ Object
82 83 84 85 86 |
# File 'lib/google-play-class.rb', line 82 def (doc) if doc.css('dd[itemprop=contentRating]').length != 0 @contentrating = doc.css('dd[itemprop=contentRating]').text end end |
#get_description(doc) ⇒ Object
52 53 54 55 56 |
# File 'lib/google-play-class.rb', line 52 def get_description(doc) if doc.css('div#doc-original-text').length != 0 @description = doc.css('div#doc-original-text').text end end |
#get_genre(doc) ⇒ Object
88 89 90 91 92 |
# File 'lib/google-play-class.rb', line 88 def get_genre(doc) if doc.css('ul.doc-genres .doc-genre-link a:first-child').length != 0 @genre = doc.css('ul.doc-genres .doc-genre-link a:first-child').text end end |
#get_lengthtime(doc) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/google-play-class.rb', line 72 def get_lengthtime(doc) if doc.css('dl.doc-metadata-list dd').length != 0 doc.css('dl.doc-metadata-list dd').each{ |value| if value.text.to_s =~ /minutes/ @lengthtime = value.text.to_s end } end end |
#get_price(doc) ⇒ Object
40 41 42 43 44 |
# File 'lib/google-play-class.rb', line 40 def get_price(doc) if doc.css('.buy-wrapper .buy-border a.buy-link .buy-button-price').length != 0 @price = doc.css('.buy-wrapper .buy-border a.buy-link .buy-button-price')[0].text end end |
#get_rating(doc) ⇒ Object
46 47 48 49 50 |
# File 'lib/google-play-class.rb', line 46 def (doc) if doc.css('.doc-details-ratings-price div div.ratings').length != 0 @rating = doc.css('.doc-details-ratings-price div div.ratings')[0]['title'] end end |
#get_related(doc) ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/google-play-class.rb', line 94 def (doc) if doc.css('div#related-list ul.snippet-list li div div.details a.title').length != 0 doc.css('div#related-list ul.snippet-list li div div.details a.title').each{ |value| @related << value.text.to_s } end end |
#get_thumbnail(doc) ⇒ Object
58 59 60 61 62 |
# File 'lib/google-play-class.rb', line 58 def get_thumbnail(doc) if doc.css('div.doc-banner-icon img').length != 0 @thumbnail = doc.css('div.doc-banner-icon img')[0]['src'] end end |
#get_title(doc) ⇒ Object
35 36 37 38 39 |
# File 'lib/google-play-class.rb', line 35 def get_title(doc) if @title == "" @title = doc.css('div.doc-header-content h1.doc-header-title').text end end |