lib/better_ipaddr/methods.rb in better_ipaddr-0.3.0 vs lib/better_ipaddr/methods.rb in better_ipaddr-0.3.1
- old
+ new
@@ -128,9 +128,10 @@
# @param offset [Integer] the index within the network of the
# desired address
# @return [IPAddr] the address at the given index
def [](offset)
+ return self if offset.zero? && host?
offset2 = offset >= 0 ? offset : size + offset
self.class[to_i + offset2, family: family]
end
# Returns the number of bits allowed by the address family.