Sha256: f392c13cd337708c1aab0b5af3b0ba6f77ea56dba635f5ac54ad7589938cbfb0

Contents?: true

Size: 558 Bytes

Versions: 5

Compression:

Stored size: 558 Bytes

Contents

module Qa::Authorities
  class Mesh < Base

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qa-0.10.1 lib/qa/authorities/mesh.rb
qa-0.10.0 lib/qa/authorities/mesh.rb
qa-0.9.0 lib/qa/authorities/mesh.rb
qa-0.8.0 lib/qa/authorities/mesh.rb
qa-0.7.0 lib/qa/authorities/mesh.rb