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.
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
#description ⇒ Object
Returns the value of attribute description.
105 106 107 |
# File 'lib/google-play-class.rb', line 105 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
105 106 107 |
# File 'lib/google-play-class.rb', line 105 def id @id end |
#price ⇒ Object
Returns the value of attribute price.
105 106 107 |
# File 'lib/google-play-class.rb', line 105 def price @price end |
#rating ⇒ Object
Returns the value of attribute rating.
105 106 107 |
# File 'lib/google-play-class.rb', line 105 def @rating end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
105 106 107 |
# File 'lib/google-play-class.rb', line 105 def thumbnail @thumbnail end |
#title ⇒ Object
Returns the value of attribute title.
105 106 107 |
# File 'lib/google-play-class.rb', line 105 def title @title end |
#type ⇒ Object
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) (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 (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 |