Class: Mihari::Structs::Censys::Location

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Location

Parameters:

  • d (Hash)

Returns:



78
79
80
81
82
83
84
# File 'lib/mihari/structs/censys.rb', line 78

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

Instance Method Details

#countryString?

Returns:

  • (String, nil)


47
48
49
# File 'lib/mihari/structs/censys.rb', line 47

def country
  attributes[:country]
end

#country_codeString?

Returns:

  • (String, nil)


54
55
56
# File 'lib/mihari/structs/censys.rb', line 54

def country_code
  attributes[:country_code]
end

#to_geolocationMihari::Geolocation

Returns <description>.

Returns:



61
62
63
64
65
66
67
68
69
70
# File 'lib/mihari/structs/censys.rb', line 61

def to_geolocation
  # sometimes Censys overlooks country
  # then set geolocation as nil
  return nil if country.nil?

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