Class: GO::Ontology

Inherits:
Object
  • Object
show all
Extended by:
GermDefault
Defined in:
lib/go.rb

Constant Summary

Constants included from GermDefault

GermDefault::CACHE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GermDefault

cache, cache_load, default, has_default, method_missing

Constructor Details

#initialize(file) ⇒ Ontology

Returns a new instance of Ontology.



74
75
76
77
78
79
# File 'lib/go.rb', line 74

def initialize file
  @header = TagSet.new
  @terms = {}
  @types = []
  parse_file(file) if File.exists?(file)
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



73
74
75
# File 'lib/go.rb', line 73

def header
  @header
end

Instance Method Details

#find(pattern) ⇒ Object



89
90
91
92
93
# File 'lib/go.rb', line 89

def find pattern
  @terms.select do |id,term|
    term.name =~ pattern
  end.values
end

#inspectObject



81
82
83
# File 'lib/go.rb', line 81

def inspect
  "#<#{self.class.name}:#{object_id} @terms=#{@terms.count}>"
end

#term(id) ⇒ Object



85
86
87
# File 'lib/go.rb', line 85

def term id
  @terms[id]
end