Class: IngvQuake::Magnitude
- Inherits:
-
Object
- Object
- IngvQuake::Magnitude
- Defined in:
- lib/ingv_quake/models/magnitude.rb
Overview
The Magnitude class represents the metadata related to the magnitude of an event record
Instance Attribute Summary collapse
-
#creation_info ⇒ CreationInfo
readonly
The creation info of the magnitude.
-
#method_id ⇒ String
readonly
The method ID used to calculate the magnitude.
-
#origin_id ⇒ String
readonly
The origin ID of the magnitude.
-
#public_id ⇒ String
readonly
The public ID of the magnitude.
-
#station_count ⇒ Integer
readonly
The number of stations that contributed to the magnitude calculation.
-
#type ⇒ String
readonly
The type of the magnitude.
-
#uncertainty ⇒ Float
readonly
The uncertainty of the magnitude value.
-
#value ⇒ Float
readonly
The value of the magnitude.
Instance Method Summary collapse
-
#initialize(data) ⇒ Magnitude
constructor
Initializes a new Magnitude instance with the provided data.
Constructor Details
#initialize(data) ⇒ Magnitude
Initializes a new Magnitude instance with the provided data.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ingv_quake/models/magnitude.rb', line 21 def initialize(data) @station_count = data.fetch('stationCount', nil)&.to_i @origin_id = data.fetch('originID', nil) @type = data.fetch('type', nil) @value = data.dig('mag', 'value')&.to_f @uncertainty = data.dig('mag', 'uncertainty')&.to_f @method_id = data.fetch('methodID', nil) @creation_info = data.fetch('creationInfo', nil)&.then { |creation_info_data| CreationInfo.new(creation_info_data) } @public_id = data.fetch('publicID', nil) end |
Instance Attribute Details
#creation_info ⇒ CreationInfo (readonly)
The creation info of the magnitude.
14 15 16 |
# File 'lib/ingv_quake/models/magnitude.rb', line 14 def creation_info @creation_info end |
#method_id ⇒ String (readonly)
The method ID used to calculate the magnitude.
14 15 16 |
# File 'lib/ingv_quake/models/magnitude.rb', line 14 def method_id @method_id end |
#origin_id ⇒ String (readonly)
The origin ID of the magnitude.
14 15 16 |
# File 'lib/ingv_quake/models/magnitude.rb', line 14 def origin_id @origin_id end |
#public_id ⇒ String (readonly)
The public ID of the magnitude.
14 15 16 |
# File 'lib/ingv_quake/models/magnitude.rb', line 14 def public_id @public_id end |
#station_count ⇒ Integer (readonly)
The number of stations that contributed to the magnitude calculation.
14 15 16 |
# File 'lib/ingv_quake/models/magnitude.rb', line 14 def station_count @station_count end |
#type ⇒ String (readonly)
The type of the magnitude.
14 15 16 |
# File 'lib/ingv_quake/models/magnitude.rb', line 14 def type @type end |
#uncertainty ⇒ Float (readonly)
The uncertainty of the magnitude value.
14 15 16 |
# File 'lib/ingv_quake/models/magnitude.rb', line 14 def uncertainty @uncertainty end |
#value ⇒ Float (readonly)
The value of the magnitude.
14 15 16 |
# File 'lib/ingv_quake/models/magnitude.rb', line 14 def value @value end |