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 ⇒ Object
- #get_contentrating ⇒ Object
- #get_description ⇒ Object
- #get_genre ⇒ Object
- #get_lengthtime ⇒ Object
- #get_price ⇒ Object
- #get_rating ⇒ Object
- #get_related ⇒ Object
- #get_thumbnail ⇒ Object
- #get_title ⇒ 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() () get_description() get_thumbnail() get_actors() get_lengthtime() () get_genre() () end |
#get_actors ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/google-play-class.rb', line 65 def get_actors() 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 ⇒ Object
83 84 85 86 87 |
# File 'lib/google-play-class.rb', line 83 def () if @@doc.css('dd[itemprop=contentRating]').length != 0 @contentrating = @@doc.css('dd[itemprop=contentRating]').text end end |
#get_description ⇒ Object
53 54 55 56 57 |
# File 'lib/google-play-class.rb', line 53 def get_description() if @@doc.css('div#doc-original-text').length != 0 @description = @@doc.css('div#doc-original-text').text end end |
#get_genre ⇒ Object
89 90 91 92 93 |
# File 'lib/google-play-class.rb', line 89 def get_genre() 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 ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/google-play-class.rb', line 73 def get_lengthtime() 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 ⇒ Object
41 42 43 44 45 |
# File 'lib/google-play-class.rb', line 41 def get_price() 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 ⇒ Object
47 48 49 50 51 |
# File 'lib/google-play-class.rb', line 47 def () 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 ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/google-play-class.rb', line 95 def () 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 ⇒ Object
59 60 61 62 63 |
# File 'lib/google-play-class.rb', line 59 def get_thumbnail() if @@doc.css('div.doc-banner-icon img').length != 0 @thumbnail = @@doc.css('div.doc-banner-icon img')[0]['src'] end end |
#get_title ⇒ Object
36 37 38 39 40 |
# File 'lib/google-play-class.rb', line 36 def get_title() if @title == "" @title = @@doc.css('div.doc-header-content h1.doc-header-title').text end end |