Class: Qa::Authorities::Mesh

Inherits:
Base
  • Object
show all
Defined in:
lib/qa/authorities/mesh.rb

Instance Method Summary collapse

Instance Method Details

#allObject



13
14
15
16
# File 'lib/qa/authorities/mesh.rb', line 13

def all
  r = Qa::SubjectMeshTerm.all
  r.map { |t| { id: t.term_id, label: t.term } }
end

#find(id) ⇒ Object



8
9
10
11
# File 'lib/qa/authorities/mesh.rb', line 8

def find(id)
  r = Qa::SubjectMeshTerm.where(term_id: id).limit(1).first
  r.nil? ? nil : { id: r.term_id, label: r.term, synonyms: r.synonyms }
end

#search(q) ⇒ Object



3
4
5
6
# File 'lib/qa/authorities/mesh.rb', line 3

def search(q)
  r = Qa::SubjectMeshTerm.where('term_lower LIKE ?', "#{q}%").limit(10)
  r.map { |t| { id: t.term_id, label: t.term } }
end