File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -130,8 +130,7 @@ def initialize(database, options = {})
130130 #
131131 # If no record is found for the IP address, +get+ returns +nil+.
132132 #
133- # @param ip_address [String] a string in the standard notation. It may be
134- # IPv4 or IPv6.
133+ # @param ip_address [String, IPAddr] IPv4 or IPv6 address.
135134 #
136135 # @raise [ArgumentError] if you attempt to look up an IPv6 address in an
137136 # IPv4-only database.
@@ -153,8 +152,7 @@ def get(ip_address)
153152 # If no record is found for the IP address, the record will be +nil+ and
154153 # the prefix length will be the value for the missing network.
155154 #
156- # @param ip_address [String] a string in the standard notation. It may be
157- # IPv4 or IPv6.
155+ # @param ip_address [String, IPAddr] IPv4 or IPv6 address.
158156 #
159157 # @raise [ArgumentError] if you attempt to look up an IPv6 address in an
160158 # IPv4-only database.
@@ -163,7 +161,8 @@ def get(ip_address)
163161 #
164162 # @return [Array<(Object, Integer)>]
165163 def get_with_prefix_length ( ip_address )
166- ip = IPAddr . new ( ip_address )
164+ ip = ip_address . is_a? ( IPAddr ) ? ip_address : IPAddr . new ( ip_address )
165+
167166 # We could check the IP has the correct prefix (32 or 128) but I do not
168167 # for performance reasons.
169168
You can’t perform that action at this time.
0 commit comments