Sha256: a8b7635849cd8d7d85c7db55b9f145743a13911d4c4143def817733791419340
Contents?: true
Size: 968 Bytes
Versions: 5
Compression:
Stored size: 968 Bytes
Contents
module Bioinform module MotifModel class NamedModel attr_reader :model, :name def initialize(model, name) @model, @name = model, name end def motif_klasses Bioinform::MotifModel.constants.map{|konst| Bioinform::MotifModel.const_get(konst) }.select{|konst| konst.is_a? Class } end def motif?(object) motif_klasses.any?{|klass| object.is_a?(klass) } end private :motif_klasses, :motif? def method_missing(meth, *args, &block) result = model.public_send(meth, *args, &block) if motif?(result) && ! result.is_a?(self.class) self.class.new(result, name) else result end end # should not be delegated to self (because in that case name won't be displayed) def to_s MotifFormatter.new.format(self) end def ==(other) model == other.model && name == other.name end end end end
Version data entries
5 entries across 5 versions & 1 rubygems