Class: Bio::GFF::GFF2::MetaData

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/gff.rb

Overview

Stores GFF2 meta-data.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directive, data = nil) ⇒ MetaData

Creates a new MetaData object



765
766
767
768
# File 'lib/bio/db/gff.rb', line 765

def initialize(directive, data = nil)
  @directive = directive
  @data = data
end

Instance Attribute Details

#dataObject

data of this entry



775
776
777
# File 'lib/bio/db/gff.rb', line 775

def data
  @data
end

#directiveObject

Directive. Usually, one of “feature-ontology”, “attribute-ontology”, or “source-ontology”.



772
773
774
# File 'lib/bio/db/gff.rb', line 772

def directive
  @directive
end

Class Method Details

.parse(line) ⇒ Object

parses a line



778
779
780
781
782
# File 'lib/bio/db/gff.rb', line 778

def self.parse(line)
  directive, data = line.chomp.split(/\s+/, 2)
  directive = directive.sub(/\A\#\#/, '') if directive
  self.new(directive, data)
end

Instance Method Details

#==(other) ⇒ Object

Returns true if self == other. Otherwise, returns false.



792
793
794
795
796
797
798
799
800
# File 'lib/bio/db/gff.rb', line 792

def ==(other)
  if self.class == other.class and
      self.directive == other.directive and
      self.data == other.data then
    true
  else
    false
  end
end

#to_sObject

string representation of this meta-data



785
786
787
788
789
# File 'lib/bio/db/gff.rb', line 785

def to_s
  d = @directive.to_s.gsub(/[\r\n]+/, ' ')
  v = ' ' + @data.to_s.gsub(/[\r\n]+/, ' ') unless @data.to_s.empty?
  "\#\##{d}#{v}\n"
end