Class: IngvQuake::Magnitude

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Magnitude

Initializes a new Magnitude instance with the provided data.

Parameters:

  • data (Hash)

    A hash containing detailed information about the magnitude of an event.



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_infoCreationInfo (readonly)

The creation info of the magnitude.

Returns:



14
15
16
# File 'lib/ingv_quake/models/magnitude.rb', line 14

def creation_info
  @creation_info
end

#method_idString (readonly)

The method ID used to calculate the magnitude.

Returns:

  • (String)

    the current value of method_id



14
15
16
# File 'lib/ingv_quake/models/magnitude.rb', line 14

def method_id
  @method_id
end

#origin_idString (readonly)

The origin ID of the magnitude.

Returns:

  • (String)

    the current value of origin_id



14
15
16
# File 'lib/ingv_quake/models/magnitude.rb', line 14

def origin_id
  @origin_id
end

#public_idString (readonly)

The public ID of the magnitude.

Returns:

  • (String)

    the current value of public_id



14
15
16
# File 'lib/ingv_quake/models/magnitude.rb', line 14

def public_id
  @public_id
end

#station_countInteger (readonly)

The number of stations that contributed to the magnitude calculation.

Returns:

  • (Integer)

    the current value of station_count



14
15
16
# File 'lib/ingv_quake/models/magnitude.rb', line 14

def station_count
  @station_count
end

#typeString (readonly)

The type of the magnitude.

Returns:

  • (String)

    the current value of type



14
15
16
# File 'lib/ingv_quake/models/magnitude.rb', line 14

def type
  @type
end

#uncertaintyFloat (readonly)

The uncertainty of the magnitude value.

Returns:

  • (Float)

    the current value of uncertainty



14
15
16
# File 'lib/ingv_quake/models/magnitude.rb', line 14

def uncertainty
  @uncertainty
end

#valueFloat (readonly)

The value of the magnitude.

Returns:

  • (Float)

    the current value of value



14
15
16
# File 'lib/ingv_quake/models/magnitude.rb', line 14

def value
  @value
end