Class: Mihari::Structs::Shodan::Location

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/mihari/structs/shodan.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#country_codeString? (readonly)

Returns:

  • (String, nil)


9
# File 'lib/mihari/structs/shodan.rb', line 9

attribute :country_code, Types::String.optional

#country_nameString? (readonly)

Returns:

  • (String, nil)


13
# File 'lib/mihari/structs/shodan.rb', line 13

attribute :country_name, Types::String.optional

Class Method Details

.from_dynamic!(d) ⇒ Location

Parameters:

  • d (Hash)

Returns:



33
34
35
36
37
38
39
# File 'lib/mihari/structs/shodan.rb', line 33

def from_dynamic!(d)
  d = Types::Hash[d]
  new(
    country_code: d["country_code"],
    country_name: d["country_name"]
  )
end

Instance Method Details

#geolocationMihari::Geolocation?

Returns:

  • (Mihari::Geolocation, nil)


18
19
20
21
22
23
24
25
# File 'lib/mihari/structs/shodan.rb', line 18

def geolocation
  return nil if country_name.nil? || country_code.nil?

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