# File lib/geoip.rb, line 431
  def asn(hostname)
    ip = lookup_ip(hostname)

    if (@database_type == Edition::ASNUM)
      # Convert numeric IP address to an integer
      ipnum = iptonum(ip)
      pos = seek_record(ipnum)
    elsif (@database_type == Edition::ASNUM_V6)
      ipaddr = IPAddr.new ip
      pos = seek_record(ipaddr.to_i)
    else
      throw "Invalid GeoIP database type #{@database_type}, can't look up ASN by IP"
    end

    read_asn(pos-@database_segments[0])
  end