class Mihari::Structs::IPInfo::Response

Public Class Methods

from_dynamic!(d) click to toggle source
# File lib/mihari/structs/ipinfo.rb, line 17
def from_dynamic!(d)
  d = Types::Hash[d]

  asn = nil
  org = d["org"]
  unless org.nil?
    asn = org.split.first
    asn = normalize_asn(asn)
  end

  new(
    ip: d.fetch("ip"),
    loc: d.fetch("loc"),
    hostname: d["hostname"],
    country_code: d.fetch("country"),
    asn: asn
  )
end