Class: PlayResult

Inherits:
Object
  • Object
show all
Defined in:
lib/google-play-class.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#actorsObject

Returns the value of attribute actors.



5
6
7
# File 'lib/google-play-class.rb', line 5

def actors
  @actors
end

#contentratingObject

Returns the value of attribute contentrating.



5
6
7
# File 'lib/google-play-class.rb', line 5

def contentrating
  @contentrating
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/google-play-class.rb', line 5

def description
  @description
end

#genreObject

Returns the value of attribute genre.



5
6
7
# File 'lib/google-play-class.rb', line 5

def genre
  @genre
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/google-play-class.rb', line 5

def id
  @id
end

#lengthtimeObject

Returns the value of attribute lengthtime.



5
6
7
# File 'lib/google-play-class.rb', line 5

def lengthtime
  @lengthtime
end

#priceObject

Returns the value of attribute price.



5
6
7
# File 'lib/google-play-class.rb', line 5

def price
  @price
end

#ratingObject

Returns the value of attribute rating.



5
6
7
# File 'lib/google-play-class.rb', line 5

def rating
  @rating
end

Returns the value of attribute related.



5
6
7
# File 'lib/google-play-class.rb', line 5

def related
  @related
end

#thumbnailObject

Returns the value of attribute thumbnail.



5
6
7
# File 'lib/google-play-class.rb', line 5

def thumbnail
  @thumbnail
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/google-play-class.rb', line 5

def title
  @title
end

#typeObject

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_rating()
	get_description()
	get_thumbnail()
	get_actors()
	get_lengthtime()
	get_contentrating()
	get_genre()
	get_related()
end

#get_actorsObject



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_contentratingObject



83
84
85
86
87
# File 'lib/google-play-class.rb', line 83

def get_contentrating()
	if @@doc.css('dd[itemprop=contentRating]').length != 0
		@contentrating = @@doc.css('dd[itemprop=contentRating]').text
	end
end

#get_descriptionObject



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_genreObject



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_lengthtimeObject



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_priceObject



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_ratingObject



47
48
49
50
51
# File 'lib/google-play-class.rb', line 47

def get_rating()
	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


95
96
97
98
99
100
101
# File 'lib/google-play-class.rb', line 95

def get_related()
	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_thumbnailObject



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_titleObject



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