Class: SearchResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query, type, list) ⇒ SearchResult

Returns a new instance of SearchResult.



107
108
109
110
111
112
113
114
115
116
# File 'lib/google-play-class.rb', line 107

def initialize(query,type,list)
	@id=""
	@type=type
	@title=""
	@price=""
	@rating=""
	@description=""
	@thumbnail=""
	fillSearchData(query,type,list)
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



105
106
107
# File 'lib/google-play-class.rb', line 105

def description
  @description
end

#idObject

Returns the value of attribute id.



105
106
107
# File 'lib/google-play-class.rb', line 105

def id
  @id
end

#priceObject

Returns the value of attribute price.



105
106
107
# File 'lib/google-play-class.rb', line 105

def price
  @price
end

#ratingObject

Returns the value of attribute rating.



105
106
107
# File 'lib/google-play-class.rb', line 105

def rating
  @rating
end

#thumbnailObject

Returns the value of attribute thumbnail.



105
106
107
# File 'lib/google-play-class.rb', line 105

def thumbnail
  @thumbnail
end

#titleObject

Returns the value of attribute title.



105
106
107
# File 'lib/google-play-class.rb', line 105

def title
  @title
end

#typeObject

Returns the value of attribute type.



105
106
107
# File 'lib/google-play-class.rb', line 105

def type
  @type
end

Instance Method Details

#fillSearchData(id, type, list) ⇒ Object



118
119
120
121
122
123
124
125
# File 'lib/google-play-class.rb', line 118

def fillSearchData(id,type,list)
	get_id(list)
	get_title(list)
	get_price(list)
	get_rating(list)
	get_description(list)
	get_thumbnail(list)
end

#get_description(doc) ⇒ Object



151
152
153
154
155
# File 'lib/google-play-class.rb', line 151

def get_description(doc)
	if doc.css('div.description').length != 0
		@description = doc.css('div.description').text
	end
end

#get_id(doc) ⇒ Object



127
128
129
# File 'lib/google-play-class.rb', line 127

def get_id(doc)
	@id = doc['data-docid']
end

#get_price(doc) ⇒ Object



137
138
139
140
141
# File 'lib/google-play-class.rb', line 137

def get_price(doc)
	if doc.css('span.buy-button-price').length != 0
		@price = doc.css('span.buy-button-price').text
	end
end

#get_rating(doc) ⇒ Object



143
144
145
146
147
148
149
# File 'lib/google-play-class.rb', line 143

def get_rating(doc)
	if doc.css('div.ratings-wrapper .ratings').length != 0
		@rating = doc.css('div.ratings-wrapper .ratings')[0]['title']
	else
		@rating = "None"
	end
end

#get_thumbnail(doc) ⇒ Object



157
158
159
160
161
# File 'lib/google-play-class.rb', line 157

def get_thumbnail(doc)
	if doc.css('.thumbnail-wrapper .thumbnail img').length != 0
		@thumbnail = doc.css('.thumbnail-wrapper .thumbnail img')[0]['src']
	end
end

#get_title(doc) ⇒ Object



131
132
133
134
135
# File 'lib/google-play-class.rb', line 131

def get_title(doc)
	if doc.css('a.title').length != 0
		@title = doc.css('a.title').text
	end
end