Sha256: 2fd14560489bee7ed0fb316abd0423282952cedbaa8e8e0397b00964cde99edd

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env ruby
# Indication -- oddb -- 12.05.2003 -- hwyss@ywesee.com 

require 'util/language'
require 'util/searchterms'
require 'model/registration_observer'
require 'model/sequence_observer'

module ODDB
	class Indication
		include Language
		include RegistrationObserver
		include SequenceObserver
		ODBA_SERIALIZABLE = [ '@descriptions', '@synonyms' ]
		def atc_classes
			atcs = @registrations.inject([]) do |memo, reg| 
				memo.concat reg.atc_classes
      end
      @sequences.each { |seq| atcs.push seq.atc_class }
      atcs.compact.uniq
		end
    def empty?
      @registrations.empty? && @sequences.empty?
    end
		def search_text(lang=nil)
      if(lang)
        super
      else
        ODDB.search_term(self.all_descriptions.join(" "))
      end
		end
    def merge(other)
      if regs = other.registrations
        regs.dup.each do |reg|
          reg.indication = self
        end
      end
      if seqs = other.sequences
        seqs.dup.each do |seq|
          seq.indication = self
        end
      end
      self.synonyms.concat(other.all_descriptions - all_descriptions).uniq!
      other
    end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oddb.org-1.0.2 src/model/indication.rb
oddb.org-1.0.1 src/model/indication.rb
oddb.org-1.0.0 src/model/indication.rb