Module: TideScraper
- Defined in:
- lib/tide_scraper.rb,
lib/tide_scraper/ports.rb,
lib/tide_scraper/scraper.rb,
lib/tide_scraper/version.rb,
lib/tide_scraper/predictions.rb
Defined Under Namespace
Classes: Scraper
Constant Summary collapse
- VERSION =
"0.3.3"
Class Method Summary collapse
-
.get_next_tide(prediction) ⇒ Object
Return the next prediction for a sorted list of tides (produced by get_prediction - sorted by default).
-
.get_upcoming_tides(prediction) ⇒ Object
Given a sorted list of tides, only return tides that are in the future.
Class Method Details
.get_next_tide(prediction) ⇒ Object
Return the next prediction for a sorted list of tides (produced by get_prediction - sorted by default)
10 11 12 13 14 15 16 17 18 |
# File 'lib/tide_scraper.rb', line 10 def self.get_next_tide(prediction) prediction.each do |tide| if tide[:time] > Time.now return tide end end # Should have found a tide by now. If not, empty set return [] end |
.get_upcoming_tides(prediction) ⇒ Object
Given a sorted list of tides, only return tides that are in the future
22 23 24 25 26 27 28 29 30 |
# File 'lib/tide_scraper.rb', line 22 def self.get_upcoming_tides(prediction) future_tides = [] prediction.each do |tide| if tide[:time] > Time.now future_tides.push tide end end return future_tides end |