Need to calculate IP => int just like in here:
https://bitbucket.org/lorien/django-ipgeo/src/d19648c9b14f/ipgeo/models.py
but in ruby.
I’m pretty new in ruby, so cannot translate this into ruby:
number = struct.unpack('!L', socket.inet_aton(ip))[0]
struct, socket are python std, ip is a string like ‘127.0.0.1’
Ruby comes with an
ipaddrmodule that specifies anIPAddrclass that can return a representation as an integer.Here it is in
irb: