Class: IngvQuake::FocalMechanism
- Inherits:
-
Object
- Object
- IngvQuake::FocalMechanism
- 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
-
#creation_info ⇒ CreationInfo
readonly
The creation information for the focal mechanism.
-
#evaluation_mode ⇒ String
readonly
The evaluation mode of the focal mechanism.
-
#evaluation_status ⇒ String
readonly
The evaluation status of the focal mechanism.
-
#moment_tensor ⇒ MomentTensor
readonly
The moment tensor information for the focal mechanism.
-
#nodal_plane1 ⇒ Hash
readonly
The first nodal plane of the focal mechanism.
-
#nodal_plane2 ⇒ Hash
readonly
The second nodal plane of the focal mechanism.
-
#public_id ⇒ String
readonly
Resource identifier of FocalMechanism.
-
#triggering_origin_id ⇒ String
readonly
Refers to the publicID of the triggering origin.
Instance Method Summary collapse
-
#initialize(data) ⇒ FocalMechanism
constructor
Initializes a new FocalMechanism instance with the provided data.
- #parse_nodal_plane(plane_data) ⇒ Object
- #parse_nodal_planes(planes) ⇒ Object
Constructor Details
#initialize(data) ⇒ FocalMechanism
Initializes a new FocalMechanism instance with the provided data.
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_info ⇒ CreationInfo (readonly)
The creation information for the focal mechanism.
14 15 16 |
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 14 def creation_info @creation_info end |
#evaluation_mode ⇒ String (readonly)
The evaluation mode of the focal mechanism.
14 15 16 |
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 14 def evaluation_mode @evaluation_mode end |
#evaluation_status ⇒ String (readonly)
The evaluation status of the focal mechanism.
14 15 16 |
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 14 def evaluation_status @evaluation_status end |
#moment_tensor ⇒ MomentTensor (readonly)
The moment tensor information for the focal mechanism.
14 15 16 |
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 14 def moment_tensor @moment_tensor end |
#nodal_plane1 ⇒ Hash (readonly)
The first nodal plane of the focal mechanism.
14 15 16 |
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 14 def nodal_plane1 @nodal_plane1 end |
#nodal_plane2 ⇒ Hash (readonly)
The second nodal plane of the focal mechanism.
14 15 16 |
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 14 def nodal_plane2 @nodal_plane2 end |
#public_id ⇒ String (readonly)
Resource identifier of FocalMechanism.
14 15 16 |
# File 'lib/ingv_quake/models/focal_mechanism.rb', line 14 def public_id @public_id end |
#triggering_origin_id ⇒ String (readonly)
Refers to the publicID of the triggering origin.
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 |