Class: Acromine
- Inherits:
-
Object
- Object
- Acromine
- Includes:
- HTTParty
- Defined in:
- lib/acromine/core.rb,
lib/acromine/version.rb,
lib/acromine/longform.rb,
lib/acromine/longform_variant.rb
Overview
a client for the Acromine REST service
Defined Under Namespace
Classes: Longform, LongformVariant
Constant Summary collapse
- DEFAULT_URI =
the URL to the Acromine REST service
'http://www.nactem.ac.uk/software/acromine/dictionary.py'- VERSION =
the version of the gem
'0.1.1'
Instance Method Summary collapse
-
#initialize(uri = DEFAULT_URI) ⇒ Acromine
constructor
constructs an Acromine object.
-
#longforms(acronym, opts = {}) ⇒ Array<Acromine::Longform>, []
finds the long form(s) of an acronym.
Constructor Details
#initialize(uri = DEFAULT_URI) ⇒ Acromine
constructs an Acromine object
15 16 17 18 |
# File 'lib/acromine/core.rb', line 15 def initialize(uri = DEFAULT_URI) self.class.base_uri uri self.class.format :json end |
Instance Method Details
#longforms(acronym, opts = {}) ⇒ Array<Acromine::Longform>, []
finds the long form(s) of an acronym
25 26 27 28 29 30 31 32 33 |
# File 'lib/acromine/core.rb', line 25 def longforms(acronym, opts = {}) # validate our options validate_opts(opts) # get the acronyms from the webservice ret = self.class.get('', query: { sf: acronym }) # an empty JSON array means the acronym was not found return [] if ret.body == "[]\n" build_lfs(ret, opts) end |