Class: Mihari::Structs::GreyNoise::Metadata

Inherits:
Dry::Struct
  • Object
show all
Includes:
Concerns::AutonomousSystemNormalizable
Defined in:
lib/mihari/structs/greynoise.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::AutonomousSystemNormalizable

#normalize_asn

Instance Attribute Details

#asnString (readonly)

Returns:

  • (String)


19
# File 'lib/mihari/structs/greynoise.rb', line 19

attribute :asn, Types::String

#countryString (readonly)

Returns:

  • (String)


11
# File 'lib/mihari/structs/greynoise.rb', line 11

attribute :country, Types::String

#country_codeString (readonly)

Returns:

  • (String)


15
# File 'lib/mihari/structs/greynoise.rb', line 15

attribute :country_code, Types::String

Class Method Details

.from_dynamic!(d) ⇒ Object

Parameters:

  • d (Hash)


42
43
44
45
46
47
48
49
# File 'lib/mihari/structs/greynoise.rb', line 42

def from_dynamic!(d)
  d = Types::Hash[d]
  new(
    country: d.fetch("country"),
    country_code: d.fetch("country_code"),
    asn: d.fetch("asn")
  )
end

Instance Method Details

#asMihari::AutonomousSystem

Returns:

  • (Mihari::AutonomousSystem)


24
25
26
# File 'lib/mihari/structs/greynoise.rb', line 24

def as
  Mihari::Models::AutonomousSystem.new(asn: normalize_asn(asn))
end

#geolocationMihari::Geolocation

Returns:

  • (Mihari::Geolocation)


31
32
33
34
35
36
# File 'lib/mihari/structs/greynoise.rb', line 31

def geolocation
  Mihari::Models::Geolocation.new(
    country: country,
    country_code: country_code
  )
end