Module: Accession::Accessionable

Included in:
Sample, Submission
Defined in:
lib/accession/accession/accessionable.rb

Overview

Standard methods used by things that can be accesioned e.g sample

Defined Under Namespace

Classes: AccessionableFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ebi_aliasObject (readonly)

Returns the value of attribute ebi_alias.



10
11
12
# File 'lib/accession/accession/accessionable.rb', line 10

def ebi_alias
  @ebi_alias
end

Instance Method Details

#dateObject



16
17
18
# File 'lib/accession/accession/accessionable.rb', line 16

def date
  @date ||= Time.now.utc.iso8601
end

#ebi_alias_datestampedObject



24
25
26
# File 'lib/accession/accession/accessionable.rb', line 24

def ebi_alias_datestamped
  "#{ebi_alias}-#{date}"
end

#filenameObject



20
21
22
# File 'lib/accession/accession/accessionable.rb', line 20

def filename
  @filename ||= "#{ebi_alias_datestamped}.#{schema_type}.xml"
end

#schema_typeObject



12
13
14
# File 'lib/accession/accession/accessionable.rb', line 12

def schema_type
  @schema_type ||= self.class.to_s.demodulize.downcase
end

#to_fileObject



34
35
36
37
38
39
40
41
# File 'lib/accession/accession/accessionable.rb', line 34

def to_file
  AccessionableFile
    .open("#{schema_type}_file")
    .tap do |f|
      f.write(to_xml << "\n")
      f.original_filename = filename
    end
end

#to_xmlObject



28
29
30
31
32
# File 'lib/accession/accession/accessionable.rb', line 28

def to_xml
  xml = Builder::XmlMarkup.new
  xml.instruct!
  xml.target!
end