Sha256: bb12a1d3a938d398320e4f733371811350d34b18aee1ec95ef28d95366672658
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module Mihari module Structs module IPInfo class Response < Dry::Struct # @!attribute [r] ip # @return [String] attribute :ip, Types::String # @!attribute [r] hostname # @return [String, nil] attribute :hostname, Types::String.optional # @!attribute [r] loc # @return [String, nil] attribute :loc, Types::String.optional # @!attribute [r] country_code # @return [String, nil] attribute :country_code, Types::String.optional # @!attribute [r] asn # @return [Integer, nil] attribute :asn, Types::Int.optional class << self include Mixins::AutonomousSystem # # @param [Hash] d # # @return [Response] # def from_dynamic!(d) d = d.deep_stringify_keys d = Types::Hash[d] asn = nil asn_ = d.dig("asn", "asn") asn = normalize_asn(asn_) unless asn_.nil? new( ip: d.fetch("ip"), loc: d["loc"], hostname: d["hostname"], country_code: d["country"], asn: asn ) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.7.0 | lib/mihari/structs/ipinfo.rb |