Module: Eol
- Includes:
- HTTParty
- Defined in:
- lib/eol.rb,
lib/eol/ping.rb,
lib/eol/pages.rb,
lib/eol/search.rb,
lib/eol/version.rb,
lib/eol/collections.rb,
lib/eol/hierarchies.rb,
lib/eol/data_objects.rb,
lib/eol/hierarchy_entries.rb,
lib/eol/search_by_provider.rb,
lib/eol/provider_hierarchies.rb
Overview
The Eol namespace holds all methods and classes that interact with the Encyclopedia of Life API.
Defined Under Namespace
Classes: Collections, DataObjects, Hierarchies, HierarchyEntries, Pages, Ping, ProviderHierarchies, Search, SearchByProvider
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
-
.collections(id, query_options = {}) ⇒ Eol::Collections
Given the identifier for a collection this API will return all metadata about the collection and the items it contains.
-
.data_objects(id, query_options = {}) ⇒ Eol::DataObjects
Given the identifier for a data object this API will return all metadata about the object as submitted to EOL by the contributing content partner.
-
.hierarchies(id, query_options = {}) ⇒ Eol::Hierarchies
Lists metadata about a hierarchy such as the provider name and source URL, as well as lists all the taxa which are the root taxa of the taxonomic tree.
-
.hierarchy_entries(id, query_options = {}) ⇒ Eol::HierarchyEntries
Gives access to a single hierarchy and its internal relationships.
-
.pages(id, query_options = {}) ⇒ Eol::Pages
This method takes an EOL page identifier and returns the scientific name for that page, and optionally returns information about common names, media (text, images and videos), and references to the hierarchies which recognize the taxon described on the page.
-
.ping ⇒ Eol::Ping
Pings the EOL API.
-
.provider_hierarchies ⇒ Array<Eol::ProviderHierarchies>
This method will return references to all hierarchies supplied by EOL Content Partners.
-
.search(query, query_options = {}) ⇒ Array<Eol::Search>
Returns one page of results from the EOL API search.
-
.search_all(query) ⇒ Array<Eol::Search>
Returns all results from an EOL API search.
-
.search_by_provider(id, hierarchy_id, query_options = {}) ⇒ Array<Eol::SearchByProvider>
This method takes an integer or string which is the unique identifier for a taxon from some provider’s database, and a hierarchy_id which represents the provider and returns the EOL page ID for that taxon.
Class Method Details
.collections(id, query_options = {}) ⇒ Eol::Collections
Given the identifier for a collection this API will return all metadata about the collection and the items it contains.
162 163 164 165 166 |
# File 'lib/eol.rb', line 162 def self.collections(id, = {}) @query = { id: id }.merge!() response = get('/collections/1.0.json', query: @query) response.code == 200 ? Eol::Collections.new(response) : bad_response(response) end |
.data_objects(id, query_options = {}) ⇒ Eol::DataObjects
Given the identifier for a data object this API will return all metadata about the object as submitted to EOL by the contributing content partner
187 188 189 190 191 |
# File 'lib/eol.rb', line 187 def self.data_objects(id, = {}) @query = { id: id }.merge!() response = get('/data_objects/1.0.json', query: @query) response.code == 200 ? Eol::DataObjects.new(response) : bad_response(response) end |
.hierarchies(id, query_options = {}) ⇒ Eol::Hierarchies
Lists metadata about a hierarchy such as the provider name and source URL, as well as lists all the taxa which are the root taxa of the taxonomic tree
230 231 232 233 234 |
# File 'lib/eol.rb', line 230 def self.hierarchies(id, = {}) @query = { id: id }.merge!() response = get('/hierarchies/1.0.json', query: @query) response.code == 200 ? Eol::Hierarchies.new(response) : bad_response(response) end |
.hierarchy_entries(id, query_options = {}) ⇒ Eol::HierarchyEntries
Gives access to a single hierarchy and its internal relationships
210 211 212 213 214 |
# File 'lib/eol.rb', line 210 def self.hierarchy_entries(id, = {}) @query = { id: id }.merge!() response = get('/hierarchy_entries/1.0.json', query: @query) response.code == 200 ? Eol::HierarchyEntries.new(response) : bad_response(response) end |
.pages(id, query_options = {}) ⇒ Eol::Pages
This method takes an EOL page identifier and returns the scientific name for that page, and optionally returns information about common names, media (text, images and videos), and references to the hierarchies which recognize the taxon described on the page.
132 133 134 135 136 |
# File 'lib/eol.rb', line 132 def self.pages(id, = {}) @query = { id: id }.merge!() response = get('/pages/1.0.json', query: @query) response.code == 200 ? Eol::Pages.new(response) : bad_response(response) end |
.ping ⇒ Eol::Ping
Pings the EOL API
28 29 30 31 |
# File 'lib/eol.rb', line 28 def self.ping response = get('/ping/1.0.json') response.code == 200 ? Eol::Ping.new(response['response']['message']) : bad_response(response) end |
.provider_hierarchies ⇒ Array<Eol::ProviderHierarchies>
This method will return references to all hierarchies supplied by EOL Content Partners. The response will include the label of the hierarchy and the EOL unique ID representing the hierarchy
244 245 246 247 |
# File 'lib/eol.rb', line 244 def self.provider_hierarchies response = get('/provider_hierarchies/1.0.json') response.code == 200 ? response.map { |item| Eol::ProviderHierarchies.new(item) } : bad_response(response) end |
.search(query, query_options = {}) ⇒ Array<Eol::Search>
Returns one page of results from the EOL API search
57 58 59 60 61 |
# File 'lib/eol.rb', line 57 def self.search(query, = {}) @query = { q: query }.merge!() response = get('/search/1.0.json', query: @query) response.code == 200 ? response['results'].map { |item| Eol::Search.new(item) } : bad_response(response) end |
.search_all(query) ⇒ Array<Eol::Search>
this method does not accept query options, for a more customized search use Eol.search
Returns all results from an EOL API search
72 73 74 75 76 |
# File 'lib/eol.rb', line 72 def self.search_all(query) @query = { q: query } response = get('/search/1.0.json', query: @query) response.code == 200 ? all_pages(query, response) : bad_response(response) end |
.search_by_provider(id, hierarchy_id, query_options = {}) ⇒ Array<Eol::SearchByProvider>
This method takes an integer or string which is the unique identifier for a taxon from some provider’s database, and a hierarchy_id which represents the provider and returns the EOL page ID for that taxon.
264 265 266 267 268 |
# File 'lib/eol.rb', line 264 def self.search_by_provider(id, hierarchy_id, = {}) @query = { id: id, hierarchy_id: hierarchy_id }.merge!() response = get('/search_by_provider/1.0.json?', query: @query) response.code == 200 ? response.map { |item| Eol::SearchByProvider.new(item) } : bad_response(response) end |