Sha256: 5acfaaf625d642b2bb227aeb1e687da0b1f098c1013b2fc29fa6a43c5dc09fe5
Contents?: true
Size: 914 Bytes
Versions: 1
Compression:
Stored size: 914 Bytes
Contents
# frozen_string_literal: true 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 asn_ = d.dig("asn", "asn") unless asn_.nil? 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mihari-3.12.0 | lib/mihari/structs/ipinfo.rb |