Class: OboParser::OboParser::Stanza

Inherits:
Object
  • Object
show all
Defined in:
lib/obo_parser.rb

Overview

A collection of single lines (Tags)

Direct Known Subclasses

Term, Typedef

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tags) ⇒ Stanza

Returns a new instance of Stanza.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/obo_parser.rb', line 58

def initialize(tags)
  @other_tags = []

  while tags.length != 0
    t = tags.shift

    new_tag = OboParser::Tag.new
    
    new_tag.tag = t.tag
    new_tag.value = t.value
    new_tag.comment = t.comment
    new_tag.xrefs = t.xrefs 

    case new_tag.tag
    when 'id' 
      @id = new_tag
    when 'name'
      @name = new_tag
    when 'def'
      @def = new_tag
    else
      if new_tag.tag == 'relationship'
        new_tag.related_term = t.related_term
        new_tag.relation = t.relation
      end

      @other_tags.push(new_tag)
    end
  end
end

Instance Attribute Details

#defObject

Make special reference to several specific types of tags (:name, :id), subclasses will remove additional special typs from :other_tags



56
57
58
# File 'lib/obo_parser.rb', line 56

def def
  @def
end

#idObject

Make special reference to several specific types of tags (:name, :id), subclasses will remove additional special typs from :other_tags



56
57
58
# File 'lib/obo_parser.rb', line 56

def id
  @id
end

#nameObject

Make special reference to several specific types of tags (:name, :id), subclasses will remove additional special typs from :other_tags



56
57
58
# File 'lib/obo_parser.rb', line 56

def name
  @name
end

#other_tagsObject

Make special reference to several specific types of tags (:name, :id), subclasses will remove additional special typs from :other_tags



56
57
58
# File 'lib/obo_parser.rb', line 56

def other_tags
  @other_tags
end

Instance Method Details

#tags_named(tag_name = nil) ⇒ Object

Convienience methods



91
92
93
94
95
96
97
98
# File 'lib/obo_parser.rb', line 91

def tags_named(tag_name = nil)
  return nil if tag_name.nil?
  result = []
  @other_tags.each do |t|
    result.push(t) if (t.tag == tag_name)
  end
  result
end