Project

twm-ruby

0.0
No commit activity in last 3 years
No release in over 3 years
A Ruby gem for interacting with The Whale Museum API's.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

>= 0.8.7
~> 1.7.3
 Project Readme

The Whale Museum API's

A Ruby gem for interacting with The Whale Museum API's.

Installation

Add this line to your application's Gemfile:

gem 'twm-ruby'

Usage

Currently only the Whale Hotline API is supported. There is no authentication required, however usage of the API requires that The Whale Museum receive full acknowledgment as the data source through citation where the data is used.

require 'twm-ruby'

twm = TWM::API.new

total_count = twm.sightings.count
=> 17829

sightings = twm.sightings.search(limit: 1000)
=> [...]

orca_count = twm.sightings.count(species: 'orca')
=> 17179

pages = (orca_count.to_f/1000.to_f).ceil
orca_sightings = []
1.upto(pages) do |page|
  orca_sightings.concat twm.sightings.search(limit: 1000, page: page)
end

orca_sightings.first['id']
=> "52c4a6da686f741c25000000"

sighting = twm.sightings.find("52c4a6da686f741c25000000")
sighting['species']
=> 'orca'