Sha256: 410e26777a2f19f503e31330cbb863f17627c959f19c41f1d552ac2e5e8b313c
Contents?: true
Size: 905 Bytes
Versions: 5
Compression:
Stored size: 905 Bytes
Contents
require "json" require "dry/struct" module Mihari module Structs module IPInfo class Response < Dry::Struct attribute :ip, Types::String attribute :hostname, Types::String.optional attribute :loc, Types::String attribute :country_code, Types::String attribute :asn, Types::Integer.optional class << self include Mixins::AutonomousSystem 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 end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems