Module: BokChoy
- Extended by:
- Configuration
- Defined in:
- lib/bok_choy.rb,
lib/bok_choy/error.rb,
lib/bok_choy/request.rb,
lib/bok_choy/version.rb
Overview
The BokChoy module provides a Ruby interface to the BHL Names API
Defined Under Namespace
Classes: BadGateway, BadRequest, Error, GatewayTimeout, InternalServerError, NotFound, Request, ServiceUnavailable
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
-
.cached_refs(id, verbose: false) ⇒ Hash
Finds a nomenclatural event in BHL by an external ID from a data source.
-
.items(id, verbose: false) ⇒ Hash
Get metadata and taxonomic statistics for a BHL item.
-
.name_refs(name: nil, author: nil, year: nil, reference: nil, nomen_event: true, json: nil, verbose: false) ⇒ Hash
Finds BHL references for a name.
-
.page(id, verbose: false) ⇒ Hash, ...
Get BHL reference metadata by page ID.
-
.ping(verbose: false) ⇒ String
Check the API status.
-
.references(id, verbose: false) ⇒ Hash
Gets BHL reference metadata by page ID.
-
.taxon_items(taxon_name: nil, verbose: false) ⇒ Hash
Finds BHL items in which a given higher taxon is prevalent.
-
.version(verbose: false) ⇒ Hash
Check the API version.
Methods included from Configuration
Class Method Details
.cached_refs(id, verbose: false) ⇒ Hash
Finds a nomenclatural event in BHL by an external ID from a data source
46 47 48 49 50 51 |
# File 'lib/bok_choy.rb', line 46 def self.cached_refs(id, verbose: false) raise "ID required" if id.nil? endpoint = "cached_refs/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.items(id, verbose: false) ⇒ Hash
Get metadata and taxonomic statistics for a BHL item
59 60 61 62 63 64 |
# File 'lib/bok_choy.rb', line 59 def self.items(id, verbose: false) raise "ID required" if id.nil? endpoint = "items/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.name_refs(name: nil, author: nil, year: nil, reference: nil, nomen_event: true, json: nil, verbose: false) ⇒ Hash
Finds BHL references for a name
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bok_choy.rb', line 25 def self.name_refs(name: nil, author: nil, year: nil, reference: nil, nomen_event: true, json: nil, verbose: false) raise "Name or json required" if name.nil? && json.nil? if json.nil? json = {'name': {}, 'reference': {}, 'params': {}} json[:name][:nameString] = name json[:name][:author] = unless .nil? json[:name][:year] = year unless year.nil? json[:reference][:refString] = reference unless reference.nil? json[:params][:nomenEvent] = nomen_event end endpoint = "name_refs" Request.new(endpoint: endpoint, json: json, verbose: verbose).perform end |
.page(id, verbose: false) ⇒ Hash, ...
Get BHL reference metadata by page ID
72 73 74 75 76 77 |
# File 'lib/bok_choy.rb', line 72 def self.page(id, verbose: false) raise "ID required" if id.nil? endpoint = "references/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.ping(verbose: false) ⇒ String
Check the API status
111 112 113 114 115 116 117 |
# File 'lib/bok_choy.rb', line 111 def self.ping(verbose: false) endpoint = "ping" Request.new( endpoint: endpoint, verbose: verbose ).perform end |
.references(id, verbose: false) ⇒ Hash
Gets BHL reference metadata by page ID
99 100 101 102 103 104 |
# File 'lib/bok_choy.rb', line 99 def self.references(id, verbose: false) raise "ID required" if id.nil? endpoint = "references/#{id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.taxon_items(taxon_name: nil, verbose: false) ⇒ Hash
Finds BHL items in which a given higher taxon is prevalent
85 86 87 88 89 90 91 |
# File 'lib/bok_choy.rb', line 85 def self.taxon_items(taxon_name: nil, verbose: false) raise "Taxon name required" if taxon_name.nil? taxon_url = ERB::Util.url_encode(taxon_name) endpoint = "taxon_items/#{taxon_url}" Request.new(endpoint: endpoint, verbose: verbose).perform end |