Class: Bioinform::MotifModel::NamedModel
- Inherits:
-
Object
- Object
- Bioinform::MotifModel::NamedModel
- Defined in:
- lib/bioinform/data_models/named_model.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(model, name) ⇒ NamedModel
constructor
A new instance of NamedModel.
- #method_missing(meth, *args, &block) ⇒ Object
-
#to_s ⇒ Object
should not be delegated to self (because in that case name won’t be displayed).
Constructor Details
#initialize(model, name) ⇒ NamedModel
Returns a new instance of NamedModel.
5 6 7 |
# File 'lib/bioinform/data_models/named_model.rb', line 5 def initialize(model, name) @model, @name = model, name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/bioinform/data_models/named_model.rb', line 19 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 |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/bioinform/data_models/named_model.rb', line 4 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/bioinform/data_models/named_model.rb', line 4 def name @name end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 |
# File 'lib/bioinform/data_models/named_model.rb', line 33 def ==(other) model == other.model && name == other.name end |
#to_s ⇒ Object
should not be delegated to self (because in that case name won’t be displayed)
29 30 31 |
# File 'lib/bioinform/data_models/named_model.rb', line 29 def to_s MotifFormatter.new.format(self) end |