Class: Acromine

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(uri = DEFAULT_URI) ⇒ Acromine

constructs an Acromine object

Parameters:

  • uri (String) (defaults to: DEFAULT_URI)

    the URI to the Acromine REST service



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

Parameters:

  • acronym (String)

    the acronym to expand

  • opts (Hash) (defaults to: {})

    sort and limit options

Returns:

  • (Array<Acromine::Longform>, [])

    a list of long forms for the acronym, or an empty array if the acronym was not found



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