summaryrefslogtreecommitdiff
path: root/lib/resolv.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 15:19:21 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 15:19:21 +0000
commit7d27c0a2d83f391943e0eb03c676c028b95925a1 (patch)
tree41a26587dc7c67419b48a46d3e76d3bbe3cfd52f /lib/resolv.rb
parent825e191296d67cbc066ea05f13c29769536c2da1 (diff)
fix Resolv::LOC::Coord.create.
* lib/resolv.rb (Resolv::LOC::Coord.create): fixed. [ruby-core:72567] [Bug #11912] fixed by Eric Wong and Kazuhiro NISHIYAMA. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/resolv.rb')
-rw-r--r--lib/resolv.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb
index bfff58b035..bff673c990 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -2699,10 +2699,12 @@ class Resolv
return arg
when String
coordinates = ''
- if Regex =~ arg && $1<180
- hemi = ($4[/([NE])/,1]) || ($4[/([SW])/,1]) ? 1 : -1
- coordinates = [(($1.to_i*(36e5))+($2.to_i*(6e4))+($3.to_f*(1e3)))*hemi+(2**31)].pack("N")
- (orientation ||= '') << $4[[/NS/],1] ? 'lat' : 'lon'
+ if Regex =~ arg && $1.to_f < 180
+ m = $~
+ hemi = (m[4][/[NE]/]) || (m[4][/[SW]/]) ? 1 : -1
+ coordinates = [ ((m[1].to_i*(36e5)) + (m[2].to_i*(6e4)) +
+ (m[3].to_f*(1e3))) * hemi+(2**31) ].pack("N")
+ orientation = m[4][/[NS]/] ? 'lat' : 'lon'
else
raise ArgumentError.new("not a properly formed Coord string: " + arg)
end