Class: SearchResult
- Inherits:
-
Object
- Object
- SearchResult
- Defined in:
- lib/google-play-class.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#price ⇒ Object
Returns the value of attribute price.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#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
- #fillSearchData(id, type, list) ⇒ Object
- #get_description(doc) ⇒ Object
- #get_id(doc) ⇒ Object
- #get_price(doc) ⇒ Object
- #get_rating(doc) ⇒ Object
- #get_thumbnail(doc) ⇒ Object
- #get_title(doc) ⇒ Object
-
#initialize(query, type, list) ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize(query, type, list) ⇒ SearchResult
Returns a new instance of SearchResult.
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/google-play-class.rb', line 106 def initialize(query,type,list) @id="" @type=type @title="" @price="" @rating="" @description="" @thumbnail="" fillSearchData(query,type,list) end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
104 105 106 |
# File 'lib/google-play-class.rb', line 104 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
104 105 106 |
# File 'lib/google-play-class.rb', line 104 def id @id end |
#price ⇒ Object
Returns the value of attribute price.
104 105 106 |
# File 'lib/google-play-class.rb', line 104 def price @price end |
#rating ⇒ Object
Returns the value of attribute rating.
104 105 106 |
# File 'lib/google-play-class.rb', line 104 def @rating end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
104 105 106 |
# File 'lib/google-play-class.rb', line 104 def thumbnail @thumbnail end |
#title ⇒ Object
Returns the value of attribute title.
104 105 106 |
# File 'lib/google-play-class.rb', line 104 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
104 105 106 |
# File 'lib/google-play-class.rb', line 104 def type @type end |
Instance Method Details
#fillSearchData(id, type, list) ⇒ Object
117 118 119 120 121 122 123 124 |
# File 'lib/google-play-class.rb', line 117 def fillSearchData(id,type,list) get_id(list) get_title(list) get_price(list) (list) get_description(list) get_thumbnail(list) end |
#get_description(doc) ⇒ Object
150 151 152 153 154 |
# File 'lib/google-play-class.rb', line 150 def get_description(doc) if doc.css('div.description').length != 0 @description = doc.css('div.description').text end end |
#get_id(doc) ⇒ Object
126 127 128 |
# File 'lib/google-play-class.rb', line 126 def get_id(doc) @id = doc['data-docid'] end |
#get_price(doc) ⇒ Object
136 137 138 139 140 |
# File 'lib/google-play-class.rb', line 136 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
142 143 144 145 146 147 148 |
# File 'lib/google-play-class.rb', line 142 def (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
156 157 158 159 160 |
# File 'lib/google-play-class.rb', line 156 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
130 131 132 133 134 |
# File 'lib/google-play-class.rb', line 130 def get_title(doc) if doc.css('a.title').length != 0 @title = doc.css('a.title').text end end |