Class: ESpider::Front::Baidu::Map::Hotel::Detail
- Inherits:
-
Object
- Object
- ESpider::Front::Baidu::Map::Hotel::Detail
- Defined in:
- lib/espider/front/baidu/map/hotel/detail.rb
Constant Summary collapse
- HotelUri =
"http://map.baidu.com/detail"
Instance Method Summary collapse
- #hotel_addr ⇒ Object
- #hotel_category ⇒ Object
- #hotel_facility ⇒ Object
- #hotel_geo ⇒ Object
- #hotel_image(uid) ⇒ Object
- #hotel_name ⇒ Object
- #hotel_price ⇒ Object
- #hotel_review ⇒ Object
- #hotel_short_comm ⇒ Object
- #hotel_star ⇒ Object
- #hotel_tel ⇒ Object
-
#initialize(uid) ⇒ Detail
constructor
A new instance of Detail.
Constructor Details
#initialize(uid) ⇒ Detail
Returns a new instance of Detail.
11 12 13 14 15 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 11 def initialize(uid) url = HotelUri + "?qt=ninf&uid=#{uid}" @hotel = JSON.parse HTTParty.get url true end |
Instance Method Details
#hotel_addr ⇒ Object
19 20 21 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 19 def hotel_addr @hotel['content']['addr'] end |
#hotel_category ⇒ Object
31 32 33 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 31 def hotel_category @hotel['content']['ext']['rich_info']['category'] end |
#hotel_facility ⇒ Object
37 38 39 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 37 def hotel_facility @hotel['content']['ext']['rich_info']['inner_facility'] end |
#hotel_geo ⇒ Object
25 26 27 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 25 def hotel_geo @hotel['content']['geo'].split(/;/)[0].sub(/\d+\|/,"").split(',') end |
#hotel_image(uid) ⇒ Object
50 51 52 53 54 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 50 def hotel_image(uid) url = HotelUri + "?qt=img&uid=#{uid}" parsed_json = JSON.parse HTTParty.get url parsed_json['images'].map{ |i| i['imgUrl']} end |
#hotel_name ⇒ Object
16 17 18 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 16 def hotel_name @hotel['content']['name'] end |
#hotel_price ⇒ Object
34 35 36 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 34 def hotel_price @hotel['content']['ext']['detail_info']['price'] end |
#hotel_review ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 43 def hotel_review reviews = [] @hotel['content']['ext']['review'].each do |r| reviews << r if r['name']!='elong' end reviews end |
#hotel_short_comm ⇒ Object
40 41 42 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 40 def hotel_short_comm @hotel['content']['ext']['detail_info']['short_comm'] end |
#hotel_star ⇒ Object
28 29 30 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 28 def hotel_star @hotel['content']['ext']['rich_info']['level'] end |
#hotel_tel ⇒ Object
22 23 24 |
# File 'lib/espider/front/baidu/map/hotel/detail.rb', line 22 def hotel_tel @hotel['content']['phone'] end |