Class: Cdss::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/cdss/parser.rb

Overview

The Parser class handles parsing of response data from the CDSS API into domain objects. It delegates the actual parsing work to specialized parser modules for each data type.

Class Method Summary collapse

Class Method Details

.parse_admin_calls(response) ⇒ Array<AdminCall>

Parses administrative calls data from the API response.

Examples:

Parse admin calls from response

calls = Parser.parse_admin_calls(response_data)

Parameters:

  • response (Hash)

    The API response containing administrative calls data.

Returns:

  • (Array<AdminCall>)

    Array of administrative call objects.



108
109
110
# File 'lib/cdss/parser.rb', line 108

def parse_admin_calls(response)
  Parsers::AdminCallsParser.parse_admin_calls(response)
end

.parse_call_analyses(response, type:) ⇒ Array<CallAnalysis>

Parses call analysis data from the API response.

Parameters:

  • response (Hash)

    The API response containing call analysis data.

  • type (Symbol)

    The type of analysis (:wdid or :gnis).

Returns:

  • (Array<CallAnalysis>)

    Array of call analysis objects.

Raises:

  • (ArgumentError)

    If an invalid analysis type is provided.



118
119
120
# File 'lib/cdss/parser.rb', line 118

def parse_call_analyses(response, type:)
  Parsers::AnalysisParser.parse_call_analyses(response, type: type)
end

.parse_climate_readings(response, type:) ⇒ Array<Reading>

Parses climate reading data from the API response.

Parameters:

  • response (Hash)

    The API response containing climate readings.

  • type (Symbol)

    The type of climate reading (:frost_dates, :daily, or :monthly).

Returns:

  • (Array<Reading>)

    Array of climate reading objects.

Raises:

  • (ArgumentError)

    If an invalid reading type is provided.



98
99
100
# File 'lib/cdss/parser.rb', line 98

def parse_climate_readings(response, type:)
  Parsers::ClimateParser.parse_climate_readings(response, type: type)
end

.parse_climate_stations(response) ⇒ Array<ClimateStation>

Parses climate station data from the API response.

Parameters:

  • response (Hash)

    The API response containing climate station data.

Returns:

  • (Array<ClimateStation>)

    Array of climate station objects.



88
89
90
# File 'lib/cdss/parser.rb', line 88

def parse_climate_stations(response)
  Parsers::ClimateParser.parse_climate_stations(response)
end

.parse_diversion_records(response, type:) ⇒ Array<Cdss::Models::DiversionRecord>

Parses diversion record data from the API response.

Parameters:

  • response (Hash)

    The API response containing diversion record data.

  • type (Symbol)

    The type of record (:day, :month, :year, or :stage_volume).

Returns:



151
152
153
# File 'lib/cdss/parser.rb', line 151

def parse_diversion_records(response, type:)
  Parsers::StructuresParser.parse_diversion_records(response, type: type)
end

.parse_geophysical_wells(response) ⇒ Array<Well>

Parses geophysical well data from the API response.

Examples:

Parse geophysical wells

geo_wells = Parser.parse_geophysical_wells(response_data)

Parameters:

  • response (Hash)

    The API response containing geophysical well data.

Returns:

  • (Array<Well>)

    Array of Well objects with geophysical well information.



56
57
58
# File 'lib/cdss/parser.rb', line 56

def parse_geophysical_wells(response)
  Parsers::WellParser.parse_geophysical_wells(response)
end

.parse_log_picks(response) ⇒ Array<Reading>

Parses geophysical log pick data from the API response.

Examples:

Parse log picks for a well

picks = Parser.parse_log_picks(response_data)

Parameters:

  • response (Hash)

    The API response containing log pick data.

Returns:

  • (Array<Reading>)

    Array of Reading objects containing log pick information.



66
67
68
# File 'lib/cdss/parser.rb', line 66

def parse_log_picks(response)
  Parsers::WellParser.parse_log_picks(response)
end

.parse_readings(response, timescale:) ⇒ Array<Reading>

Parses time series readings from the API response.

Examples:

Parse daily readings

readings = Parser.parse_readings(response_data, timescale: :day)

Parameters:

  • response (Hash)

    The API response containing reading data.

  • timescale (Symbol)

    The timescale of the readings (:day, :month, :year, :raw, :hour).

Returns:

  • (Array<Reading>)

    Array of Reading objects with time series data.

Raises:

  • (ArgumentError)

    If an invalid timescale is provided.



26
27
28
# File 'lib/cdss/parser.rb', line 26

def parse_readings(response, timescale:)
  Parsers::ReadingParser.parse_readings(response, timescale: timescale)
end

.parse_reference_table(response) ⇒ Array<Cdss::Models::ReferenceTable>

Parses reference table data from the API response.

Parameters:

  • response (Hash)

    The API response containing reference table data.

Returns:



167
168
169
# File 'lib/cdss/parser.rb', line 167

def parse_reference_table(response)
  Parsers::ReferenceTablesParser.parse_reference_table(response)
end

.parse_route_analyses(response) ⇒ Array<RouteAnalysis>

Parses route analysis data from the API response.

Parameters:

  • response (Hash)

    The API response containing route analysis data.

Returns:

  • (Array<RouteAnalysis>)

    Array of route analysis objects.



134
135
136
# File 'lib/cdss/parser.rb', line 134

def parse_route_analyses(response)
  Parsers::AnalysisParser.parse_route_analyses(response)
end

.parse_source_routes(response) ⇒ Array<SourceRoute>

Parses source route framework data from the API response.

Parameters:

  • response (Hash)

    The API response containing source route data.

Returns:

  • (Array<SourceRoute>)

    Array of source route objects.



126
127
128
# File 'lib/cdss/parser.rb', line 126

def parse_source_routes(response)
  Parsers::AnalysisParser.parse_source_routes(response)
end

.parse_stations(response) ⇒ Array<Station>

Parses station data from the API response.

Examples:

Parse stations from API response

stations = Parser.parse_stations(response_data)

Parameters:

  • response (Hash)

    The API response containing station data.

Returns:

  • (Array<Station>)

    Array of Station objects representing telemetry or surface water stations.



14
15
16
# File 'lib/cdss/parser.rb', line 14

def parse_stations(response)
  Parsers::StationParser.parse_stations(response)
end

.parse_structures(response) ⇒ Array<Cdss::Models::Structure>

Parses structure data from the API response.

Parameters:

  • response (Hash)

    The API response containing structure data.

Returns:



142
143
144
# File 'lib/cdss/parser.rb', line 142

def parse_structures(response)
  Parsers::StructuresParser.parse_structures(response)
end

.parse_water_classes(response) ⇒ Array<Cdss::Models::WaterClass>

Parses water class data from the API response.

Parameters:

  • response (Hash)

    The API response containing water class data.

Returns:



159
160
161
# File 'lib/cdss/parser.rb', line 159

def parse_water_classes(response)
  Parsers::StructuresParser.parse_water_classes(response)
end

.parse_water_rights(response, type:) ⇒ Array<WaterRight>

Parses water rights data from the API response.

Examples:

Parse net amounts

rights = Parser.parse_water_rights(response_data, type: :net_amount)

Parse transactions

transactions = Parser.parse_water_rights(response_data, type: :transaction)

Parameters:

  • response (Hash)

    The API response containing water rights data.

  • type (Symbol)

    The type of water rights data to parse (:net_amount or :transaction).

Returns:

  • (Array<WaterRight>)

    Array of WaterRight objects.

Raises:

  • (ArgumentError)

    If an invalid water rights type is provided.



80
81
82
# File 'lib/cdss/parser.rb', line 80

def parse_water_rights(response, type:)
  Parsers::WaterRightsParser.parse_water_rights(response, type: type)
end

.parse_well_measurements(response) ⇒ Array<Reading>

Parses well measurement data from the API response.

Examples:

Parse well measurements

measurements = Parser.parse_well_measurements(response_data)

Parameters:

  • response (Hash)

    The API response containing well measurement data.

Returns:

  • (Array<Reading>)

    Array of Reading objects containing well measurements.



46
47
48
# File 'lib/cdss/parser.rb', line 46

def parse_well_measurements(response)
  Parsers::WellParser.parse_well_measurements(response)
end

.parse_wells(response) ⇒ Array<Well>

Parses well data from the API response.

Examples:

Parse wells from response

wells = Parser.parse_wells(response_data)

Parameters:

  • response (Hash)

    The API response containing well data.

Returns:

  • (Array<Well>)

    Array of Well objects with basic well information.



36
37
38
# File 'lib/cdss/parser.rb', line 36

def parse_wells(response)
  Parsers::WellParser.parse_wells(response)
end