Skip to content

tatemae-consultancy/twm-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'

About

Ruby wrapper for The Whale Museum API's.

Resources

License

Stars

Watchers

Forks

Packages

No packages published