Module: LibTAD::Client::TidesService

Included in:
LibTAD::Client
Defined in:
lib/services/tides.rb

Overview

Tides API.

Instance Method Summary collapse

Instance Method Details

#get_tidal_data(placeid:, onlyhighlow: nil, start_date: nil, end_date: nil, radius: nil, subordinate: nil, interval: nil, localtime: nil) ⇒ Array<::LibTAD::Tides::Station>

The Tides service can be used to retrieve predicted tidal data over a given time interval for one or multiple places.

Parameters:

  • placeid (String)

    Specify the ID or a list of ID’s for a location which you would like to get tidal data for.

  • onlyhighlow (Boolean) (defaults to: nil)

    Whether to return every point per interval, or just the highest and lowest points.

  • start_date (String) (defaults to: nil)

    Start of the requested time interval.

  • end_date (String) (defaults to: nil)

    End of the requested time interval.

  • radius (Float) (defaults to: nil)

    Search for tidal stations within the radius from the requested place.

  • subordinate (Boolean) (defaults to: nil)

    Whether or not to resolve subordinate or just reference stations.

  • interval (Integer) (defaults to: nil)

    How many minutes between each data point. Supported values: 5 min, 15 min, 30 min, 60 min.

  • localtime (Boolean) (defaults to: nil)

    Whether input and output timestamps should be resolved to local time or not.

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/services/tides.rb', line 16

def get_tidal_data(
  placeid:,
  onlyhighlow: nil,
  start_date: nil,
  end_date: nil,
  radius: nil,
  subordinate: nil,
  interval: nil,
  localtime: nil
)
  args = {
    placeid: placeid,
    onlyhighlow: onlyhighlow,
    startdt: start_date,
    enddt: end_date,
    radius: radius,
    subordinate: subordinate,
    interval: interval,
    localtime: localtime
  }.compact

  response = get('tides', args)
  stations = response.fetch('stations', [])

  return stations.collect do |e|
    ::LibTAD::Tides::Station.new(e)
  end
end