Skip to content

Commit 1e05d06

Browse files
committed
Use Regexp#match to achieve matched data
This method is available since ruby 1.9.0.
1 parent 451d3f3 commit 1e05d06

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/resolv.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3344,10 +3344,9 @@ def self.create(arg)
33443344
when Coord
33453345
return arg
33463346
when String
3347-
unless Regex =~ arg && $1.to_f < 180
3347+
unless (m = Regex.match(arg)) && m[1].to_i < 180
33483348
raise ArgumentError.new("not a properly formed Coord string: " + arg)
33493349
end
3350-
m = $~
33513350
hemi = (m[4][/[NE]/]) || (m[4][/[SW]/]) ? 1 : -1
33523351
coordinates = [ ((m[1].to_i*(36e5)) + (m[2].to_i*(6e4)) +
33533352
(m[3].to_f*(1e3))) * hemi+(2**31) ].pack("N")

0 commit comments

Comments
 (0)