Class: Mihari::Structs::MMDB::CountryInfo

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#latitudeString (readonly)

Returns:

  • (String)


29
# File 'lib/mihari/structs/mmdb.rb', line 29

attribute :latitude, Types::String

#longitudeString (readonly)

Returns:

  • (String)


33
# File 'lib/mihari/structs/mmdb.rb', line 33

attribute :longitude, Types::String

Class Method Details

.from_dynamic!(d) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/mihari/structs/mmdb.rb', line 35

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    latitude: d.fetch("Latitude (average)"),
    longitude: d.fetch("Longitude (average)")
  )
end

.from_json!(json) ⇒ Object



44
45
46
# File 'lib/mihari/structs/mmdb.rb', line 44

def from_json!(json)
  from_dynamic!(JSON.parse(json))
end