holden-hostelify 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/hostelify.gemspec +1 -1
- data/lib/hostel/hostel.rb +3 -3
- data/lib/hostel/hostelbookers.rb +5 -5
- data/lib/hostel/hostelworld.rb +6 -6
- data/spec/_helper.rb +1 -1
- metadata +1 -1
data/hostelify.gemspec
CHANGED
data/lib/hostel/hostel.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class Hostelify
|
2
2
|
attr_accessor :hostel_id, :name, :address, :description, :facilities, :ratings, :directions, :geo, :images, :video, :availability
|
3
3
|
attr_accessor :rating, :dorm, :single, :unavailable
|
4
4
|
|
@@ -11,7 +11,7 @@ class Hostel
|
|
11
11
|
|
12
12
|
end
|
13
13
|
|
14
|
-
class
|
14
|
+
class HostelifyCollection < Array
|
15
15
|
# This collection does everything an Array does, plus
|
16
16
|
# you can add utility methods like names.
|
17
17
|
|
@@ -35,7 +35,7 @@ class HostelCollection < Array
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
-
class
|
38
|
+
class HostelifyAvailable
|
39
39
|
attr_accessor :name, :price, :spots, :bookdate
|
40
40
|
|
41
41
|
def initialize(name, price, spots, bookdate)
|
data/lib/hostel/hostelbookers.rb
CHANGED
@@ -25,7 +25,7 @@ class Hostelbookers
|
|
25
25
|
|
26
26
|
data = data.search("//div[@id='propertyResultsList']")
|
27
27
|
#@results = []
|
28
|
-
@results =
|
28
|
+
@results = HostelifyCollection.new
|
29
29
|
#coder = HTMLEntities.new
|
30
30
|
(data/"tr.propertyRow").each do |row|
|
31
31
|
name = row.at("a.propertyTitle").inner_text
|
@@ -37,8 +37,8 @@ class Hostelbookers
|
|
37
37
|
single = row.at("td.private/text()")
|
38
38
|
hb_id = url.match(/[\d]{2,5}.$/).to_s.to_i
|
39
39
|
|
40
|
-
#@results <<
|
41
|
-
@results <<
|
40
|
+
#@results << Hostelify.new(:hostel_id => hb_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single)
|
41
|
+
@results << Hostelify.new(:hostel_id => hb_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single)
|
42
42
|
end
|
43
43
|
return @results
|
44
44
|
end
|
@@ -49,7 +49,7 @@ class Hostelbookers
|
|
49
49
|
id = options[:id]
|
50
50
|
url = HB_SINGULAR_DETAIL_URL + "#{country}/#{city}/#{id}"
|
51
51
|
|
52
|
-
hostel =
|
52
|
+
hostel = Hostelify.new
|
53
53
|
|
54
54
|
if options[:date]
|
55
55
|
options = @default_options.merge(options)
|
@@ -118,7 +118,7 @@ class Hostelbookers
|
|
118
118
|
price = price.inner_text.to_s.match(/[\d.]{1,5}/)[0] unless price.nil?
|
119
119
|
(0..(options[:no_days].to_i-1)).each do |x|
|
120
120
|
#@availables << { :name => name, :spots => people, :price => price, :bookdate => (date+x).to_s } unless price.nil?
|
121
|
-
@availables <<
|
121
|
+
@availables << HostelifyAvailable.new(name,price,people,(date+x).to_s) unless price.nil?
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
data/lib/hostel/hostelworld.rb
CHANGED
@@ -25,7 +25,7 @@ class Hostelworld
|
|
25
25
|
url = HW_SINGULAR_DETAIL_URL + id
|
26
26
|
|
27
27
|
#coder = HTMLEntities.new
|
28
|
-
hostel =
|
28
|
+
hostel = Hostelify.new
|
29
29
|
hostel.hostel_id = id
|
30
30
|
|
31
31
|
if options[:date]
|
@@ -107,7 +107,7 @@ class Hostelworld
|
|
107
107
|
end
|
108
108
|
|
109
109
|
data = data.search("//div[@id='content']")
|
110
|
-
@results =
|
110
|
+
@results = HostelifyCollection.new
|
111
111
|
|
112
112
|
(data/"div.hostelListing").each do |row|
|
113
113
|
name = row.at("h3").inner_text
|
@@ -124,9 +124,9 @@ class Hostelworld
|
|
124
124
|
single = row.at("p.hostelListingPrivateRate/span.blueBeds/text()").to_s.gsub(/[A-Z$]*/,'')
|
125
125
|
available = row/"ul.hostelListingDates/li.noAvail/text()"
|
126
126
|
available = available.to_a.join(',').split(',')
|
127
|
-
@results <<
|
127
|
+
@results << Hostelify.new(:hostel_id => hostel_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single, :unavailable => available)
|
128
128
|
else
|
129
|
-
@results <<
|
129
|
+
@results << Hostelify.new(:hostel_id => hostel_id, :name => name, :description => desc, :rating => rating)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
return @results
|
@@ -190,9 +190,9 @@ class Hostelworld
|
|
190
190
|
|
191
191
|
if available
|
192
192
|
beds = available.to_s.match(/[\d]{1,2}/)[0]
|
193
|
-
availables <<
|
193
|
+
availables << HostelifyAvailable.new(name,price,beds,date)
|
194
194
|
else
|
195
|
-
availables <<
|
195
|
+
availables << HostelifyAvailable.new(name,price,0,date)
|
196
196
|
end
|
197
197
|
end
|
198
198
|
end
|
data/spec/_helper.rb
CHANGED