Class: IngvQuake::FocalMechanism

Inherits:
Object
  • Object
show all
Defined in:
lib/ingv_quake/models/focal_mechanism.rb

Overview

The FocalMechanism class represents the focal mechanism information of an event.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ FocalMechanism

Initializes a new FocalMechanism instance with the provided data.

Parameters:

  • data (Hash)

    A hash containing detailed information about the data used for an event focal mechanism.



21
22
23
24
25
26
27
28
29
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 21

def initialize(data)
  @public_id = data.fetch('publicID', nil)
  @triggering_origin_id = data.fetch('triggeringOriginID', nil)
  @nodal_plane1, @nodal_plane2 = parse_nodal_planes(data.fetch('nodalPlanes', {}))
  @creation_info = data.fetch('creationInfo', nil)&.then { |creation_info_data| CreationInfo.new(creation_info_data) }
  @evaluation_mode = data.fetch('evaluationMode', nil)
  @evaluation_status = data.fetch('evaluationStatus', nil)
  @moment_tensor = data.fetch('momentTensor', nil)&.then { |moment_tensor_data| MomentTensor.new(moment_tensor_data) }
end

Instance Attribute Details

#creation_infoCreationInfo (readonly)

The creation information for the focal mechanism.

Returns:



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

def creation_info
  @creation_info
end

#evaluation_modeString (readonly)

The evaluation mode of the focal mechanism.

Returns:

  • (String)

    the current value of evaluation_mode



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

def evaluation_mode
  @evaluation_mode
end

#evaluation_statusString (readonly)

The evaluation status of the focal mechanism.

Returns:

  • (String)

    the current value of evaluation_status



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

def evaluation_status
  @evaluation_status
end

#moment_tensorMomentTensor (readonly)

The moment tensor information for the focal mechanism.

Returns:



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

def moment_tensor
  @moment_tensor
end

#nodal_plane1Hash (readonly)

The first nodal plane of the focal mechanism.

Returns:

  • (Hash)

    the current value of nodal_plane1



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

def nodal_plane1
  @nodal_plane1
end

#nodal_plane2Hash (readonly)

The second nodal plane of the focal mechanism.

Returns:

  • (Hash)

    the current value of nodal_plane2



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

def nodal_plane2
  @nodal_plane2
end

#public_idString (readonly)

Resource identifier of FocalMechanism.

Returns:

  • (String)

    the current value of public_id



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

def public_id
  @public_id
end

#triggering_origin_idString (readonly)

Refers to the publicID of the triggering origin.

Returns:

  • (String)

    the current value of triggering_origin_id



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

def triggering_origin_id
  @triggering_origin_id
end

Instance Method Details

#parse_nodal_plane(plane_data) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 37

def parse_nodal_plane(plane_data)
  {
    strike: plane_data.dig('strike', 'value')&.to_i,
    dip: plane_data.dig('dip', 'value')&.to_i,
    rake: plane_data.dig('rake', 'value')&.to_i
  }
end

#parse_nodal_planes(planes) ⇒ Object



31
32
33
34
35
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 31

def parse_nodal_planes(planes)
  nodal_plane1 = parse_nodal_plane(planes.fetch('nodalPlane1', {}))
  nodal_plane2 = parse_nodal_plane(planes.fetch('nodalPlane2', {}))
  [nodal_plane1, nodal_plane2]
end