woefoo 0.0.9 → 0.0.10
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/lib/woefoo/version.rb +1 -1
- data/lib/woefoo.rb +13 -2
- metadata +3 -3
data/lib/woefoo/version.rb
CHANGED
data/lib/woefoo.rb
CHANGED
@@ -56,7 +56,7 @@ module Woefoo
|
|
56
56
|
if opts.include?(:query)
|
57
57
|
s = opts[:query]
|
58
58
|
else
|
59
|
-
[:line1, :city, :
|
59
|
+
[:line1, :city, :state, :postal, :country].each do |l|
|
60
60
|
s << "#{opts[l]} " if opts.include?(l)
|
61
61
|
end
|
62
62
|
end
|
@@ -67,7 +67,7 @@ module Woefoo
|
|
67
67
|
# Build a parameterized query url
|
68
68
|
def build_parameterized_url(opts={})
|
69
69
|
s = ""
|
70
|
-
|
70
|
+
build_query_keys(opts).each do |l|
|
71
71
|
if opts.include?(l)
|
72
72
|
val = ::CGI.escape(opts[l])
|
73
73
|
s << "&#{l.to_s}=#{val} "
|
@@ -87,4 +87,15 @@ module Woefoo
|
|
87
87
|
tr = Typhoeus::Request.get(url)
|
88
88
|
Woefoo::Response.new(opts, tr) if tr
|
89
89
|
end
|
90
|
+
|
91
|
+
def build_query_keys(opts={})
|
92
|
+
k = [:line1, :city, :state, :postal, :country]
|
93
|
+
if opts.include?(:country)
|
94
|
+
if opts[:country] != "US" && opts[:country] != "CA"
|
95
|
+
k.delete(:state)
|
96
|
+
k.delete(:postal)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
k
|
100
|
+
end
|
90
101
|
end
|
metadata
CHANGED