Sha256: efd3c9a37e9ab21e41f5606e60dc37619d6ab32d7ec51fb5c7d7fe83c77c71eb

Contents?: true

Size: 559 Bytes

Versions: 6

Compression:

Stored size: 559 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

6 entries across 6 versions & 1 rubygems

Version Path
qa-0.6.0 lib/qa/authorities/mesh.rb
qa-0.5.0 lib/qa/authorities/mesh.rb
qa-0.4.3 lib/qa/authorities/mesh.rb
qa-0.4.2 lib/qa/authorities/mesh.rb
qa-0.4.1 lib/qa/authorities/mesh.rb
qa-0.4.0 lib/qa/authorities/mesh.rb