libtad 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/libtad.rb +6 -0
- data/lib/services/tides.rb +46 -0
- data/lib/types/tides/station.rb +27 -0
- data/lib/types/tides/station_info.rb +34 -0
- data/lib/types/tides/tide.rb +25 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 977d138cf0263513fe4fc2277d3b96b4523b81df1c6983627e34fbaf59279237
|
4
|
+
data.tar.gz: 9de6d875879d0e2c53fa042252cc3313e837bba78321733059a351a841a85ac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad223d7da22ac8dc49bdad384b37aa7234654b640391de8c77f209d8b412b05b63b0e6aa32b05d6f614288ab50400ef2ec17178a5017d37684a5c86414e84702
|
7
|
+
data.tar.gz: ec0317e7e358248d95540913361bb49e03e7390e2667449d8ab22dbff95c07693162448cd5e803fc0e4d3ee6773d87ff5162fccbbb04e04cb719b6f70bcd5821
|
data/lib/libtad.rb
CHANGED
@@ -3,6 +3,7 @@ require 'services/date_calculator'
|
|
3
3
|
require 'services/holidays'
|
4
4
|
require 'services/onthisday'
|
5
5
|
require 'services/places'
|
6
|
+
require 'services/tides'
|
6
7
|
require 'services/time'
|
7
8
|
|
8
9
|
require 'types/astronomy/astronomy_current'
|
@@ -37,6 +38,10 @@ require 'types/places/location_ref'
|
|
37
38
|
require 'types/places/place'
|
38
39
|
require 'types/places/region'
|
39
40
|
|
41
|
+
require 'types/tides/station'
|
42
|
+
require 'types/tides/station_info'
|
43
|
+
require 'types/tides/tide'
|
44
|
+
|
40
45
|
require 'types/time/datetime'
|
41
46
|
require 'types/time/dst_entry'
|
42
47
|
require 'types/time/time'
|
@@ -57,6 +62,7 @@ module LibTAD
|
|
57
62
|
include LibTAD::Client::HolidaysService
|
58
63
|
include LibTAD::Client::OnThisDayService
|
59
64
|
include LibTAD::Client::PlacesService
|
65
|
+
include LibTAD::Client::TidesService
|
60
66
|
include LibTAD::Client::TimeService
|
61
67
|
|
62
68
|
# The endpoint the client connects to.
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module LibTAD
|
2
|
+
class Client
|
3
|
+
# Tides API.
|
4
|
+
module TidesService
|
5
|
+
# @return [Array<::LibTAD::Tides::Station>]
|
6
|
+
# @param placeid [String] Specify the ID or a list of ID's for a location which you would like to get tidal data for.
|
7
|
+
# @param onlyhighlow [Boolean] Whether to return every point per interval, or just the highest and lowest points.
|
8
|
+
# @param start_date [String] Start of the requested time interval.
|
9
|
+
# @param end_date [String] End of the requested time interval.
|
10
|
+
# @param radius [Float] Search for tidal stations within the radius from the requested place.
|
11
|
+
# @param subordinate [Boolean] Whether or not to resolve subordinate or just reference stations.
|
12
|
+
# @param interval [Integer] How many minutes between each data point. Supported values: 5 min, 15 min, 30 min, 60 min.
|
13
|
+
# @param localtime [Boolean] Whether input and output timestamps should be resolved to local time or not.
|
14
|
+
#
|
15
|
+
# The Tides service can be used to retrieve predicted tidal data over a given time interval for one or multiple places.
|
16
|
+
def get_tidal_data(
|
17
|
+
placeid:,
|
18
|
+
onlyhighlow: nil,
|
19
|
+
start_date: nil,
|
20
|
+
end_date: nil,
|
21
|
+
radius: nil,
|
22
|
+
subordinate: nil,
|
23
|
+
interval: nil,
|
24
|
+
localtime: nil
|
25
|
+
)
|
26
|
+
args = {
|
27
|
+
placeid: placeid,
|
28
|
+
onlyhighlow: onlyhighlow,
|
29
|
+
startdt: start_date,
|
30
|
+
enddt: end_date,
|
31
|
+
radius: radius,
|
32
|
+
subordinate: subordinate,
|
33
|
+
interval: interval,
|
34
|
+
localtime: localtime
|
35
|
+
}.compact
|
36
|
+
|
37
|
+
response = get('tides', args)
|
38
|
+
stations = response.fetch('stations', [])
|
39
|
+
|
40
|
+
return stations.collect do |e|
|
41
|
+
::LibTAD::Tides::Station.new(e)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module LibTAD
|
2
|
+
module Tides
|
3
|
+
# Predicted data for a given station.
|
4
|
+
class Station
|
5
|
+
# @return [StationInfo]
|
6
|
+
# The source station for the predicted tidal data.
|
7
|
+
attr_reader :source
|
8
|
+
|
9
|
+
# @return [String]
|
10
|
+
# The part of the queried placeid that this location matches.
|
11
|
+
attr_reader :matchparam
|
12
|
+
|
13
|
+
# @return [Array<Tide>]
|
14
|
+
# Requested tidal information.
|
15
|
+
attr_reader :result
|
16
|
+
|
17
|
+
|
18
|
+
def initialize(hash)
|
19
|
+
@source = StationInfo.new hash.fetch('source', nil)
|
20
|
+
|
21
|
+
@matchparam = hash.fetch('matchparam', nil)
|
22
|
+
@result = hash.fetch('result', nil)
|
23
|
+
&.map { |e| Tide.new(e) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module LibTAD
|
2
|
+
module Tides
|
3
|
+
# Information about a station.
|
4
|
+
class StationInfo
|
5
|
+
# @return [String]
|
6
|
+
# Station name.
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
# @return [Float]
|
10
|
+
# Latitude coordinates of the station.
|
11
|
+
attr_reader :latitude
|
12
|
+
|
13
|
+
# @return [Float]
|
14
|
+
# Longitude coordinates of the station.
|
15
|
+
attr_reader :longitude
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
# Station type. Either reference or subordinate station.
|
19
|
+
attr_reader :type
|
20
|
+
|
21
|
+
# @return [Float]
|
22
|
+
# Distance between request place and this station.
|
23
|
+
attr_reader :distance
|
24
|
+
|
25
|
+
def initialize(hash)
|
26
|
+
@name = hash.fetch('name', nil)
|
27
|
+
@latitude = hash.fetch('latitude', nil)
|
28
|
+
@longitude = hash.fetch('longitude', nil)
|
29
|
+
@type = hash.fetch('type', nil)
|
30
|
+
@distance = hash.fetch('distance', nil)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
module LibTAD
|
3
|
+
module Tides
|
4
|
+
# Information about the tide at a specific point in time.
|
5
|
+
class Tide
|
6
|
+
# @return [::LibTAD::TADTime::TADTime]
|
7
|
+
# Date/time of the specific tidal data point.
|
8
|
+
attr_reader :time
|
9
|
+
|
10
|
+
# @return [Float]
|
11
|
+
# The elevation of tidal water above or below mean sea level.
|
12
|
+
attr_reader :amplitude
|
13
|
+
|
14
|
+
# @return [TidalPhase]
|
15
|
+
# The current tidal phase.
|
16
|
+
attr_reader :phase
|
17
|
+
|
18
|
+
def initialize(hash)
|
19
|
+
@time = ::LibTAD::TADTime::TADTime.new hash.fetch('time', nil)
|
20
|
+
@amplitude = hash.fetch('amplitude', nil)
|
21
|
+
@phase = hash.fetch('phase', nil)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libtad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Alvsåker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.10
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/services/holidays.rb
|
79
79
|
- lib/services/onthisday.rb
|
80
80
|
- lib/services/places.rb
|
81
|
+
- lib/services/tides.rb
|
81
82
|
- lib/services/time.rb
|
82
83
|
- lib/types/astronomy/astronomy_current.rb
|
83
84
|
- lib/types/astronomy/astronomy_day.rb
|
@@ -106,6 +107,9 @@ files:
|
|
106
107
|
- lib/types/places/location_ref.rb
|
107
108
|
- lib/types/places/place.rb
|
108
109
|
- lib/types/places/region.rb
|
110
|
+
- lib/types/tides/station.rb
|
111
|
+
- lib/types/tides/station_info.rb
|
112
|
+
- lib/types/tides/tide.rb
|
109
113
|
- lib/types/time/datetime.rb
|
110
114
|
- lib/types/time/dst_entry.rb
|
111
115
|
- lib/types/time/time.rb
|