Class: IngvQuake::FullInfoEventParser

Inherits:
ApplicationService show all
Defined in:
lib/ingv_quake/services/full_info_event_parser.rb

Overview

The FullInfoEventParser class is responsible for parsing response data containing full information about earthquake events. It inherits from the ApplicationService base class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationService

call

Constructor Details

#initialize(response) ⇒ FullInfoEventParser

Initializes a new FullInfoEventParser instance with the response data.

Parameters:

  • response (Hash)

    The response data to be parsed.



13
14
15
# File 'lib/ingv_quake/services/full_info_event_parser.rb', line 13

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



8
9
10
# File 'lib/ingv_quake/services/full_info_event_parser.rb', line 8

def response
  @response
end

Instance Method Details

#callArray<FullInfoEvent>

Parses the response data and creates an array of FullInfoEvent objects.

Returns:



20
21
22
23
24
25
# File 'lib/ingv_quake/services/full_info_event_parser.rb', line 20

def call
  events = response.dig('quakeml', 'eventParameters', 'event') || []
  events = [events] if events.is_a? Hash

  events.map { |data| create_full_info_event(data) }
end