Class: StrainCode::StrainNumber
- Inherits:
-
Object
- Object
- StrainCode::StrainNumber
- Defined in:
- lib/strain_code/strain_number.rb
Instance Attribute Summary collapse
-
#accession ⇒ Object
Returns the value of attribute accession.
-
#code ⇒ Object
Returns the value of attribute code.
-
#ori_number ⇒ Object
Returns the value of attribute ori_number.
Instance Method Summary collapse
- #catalogue ⇒ Object
-
#initialize(number) ⇒ StrainNumber
constructor
A new instance of StrainNumber.
- #number ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(number) ⇒ StrainNumber
Returns a new instance of StrainNumber.
4 5 6 7 8 |
# File 'lib/strain_code/strain_number.rb', line 4 def initialize(number) @ori_number = number.to_s.strip @code, @accession = ori_number.split(/[ :_]+/, 2) @code, @accession = @accession, @code if @accession.nil? end |
Instance Attribute Details
#accession ⇒ Object
Returns the value of attribute accession.
2 3 4 |
# File 'lib/strain_code/strain_number.rb', line 2 def accession @accession end |
#code ⇒ Object
Returns the value of attribute code.
2 3 4 |
# File 'lib/strain_code/strain_number.rb', line 2 def code @code end |
#ori_number ⇒ Object
Returns the value of attribute ori_number.
2 3 4 |
# File 'lib/strain_code/strain_number.rb', line 2 def ori_number @ori_number end |
Instance Method Details
#catalogue ⇒ Object
18 19 20 |
# File 'lib/strain_code/strain_number.rb', line 18 def catalogue @catalogue ||= StrainCode.catalogue(code) end |
#number ⇒ Object
10 11 12 |
# File 'lib/strain_code/strain_number.rb', line 10 def number catalogue ? [code, accession].compact.join(' ') : ori_number end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/strain_code/strain_number.rb', line 22 def to_s number end |
#url ⇒ Object
14 15 16 |
# File 'lib/strain_code/strain_number.rb', line 14 def url catalogue.url_pattern % accession if catalogue&.url_pattern end |