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


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

def ebi_alias
  @ebi_alias
end

Instance Method Details

#dateObject


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

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

#ebi_alias_datestampedObject


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

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

#filenameObject


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

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

#schema_typeObject


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

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

#to_fileObject


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

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

#to_xmlObject


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

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