Class: Osgeo::Termbase::ConceptCollection
- Inherits:
-
Hash
- Object
- Hash
- Osgeo::Termbase::ConceptCollection
- Defined in:
- lib/osgeo/termbase/concept_collection.rb
Instance Method Summary collapse
Instance Method Details
#add_term(term) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/osgeo/termbase/concept_collection.rb', line 7 def add_term(term) if self[term.id] self[term.id].add_term(term) else self[term.id] = Concept.new( id: term.id, terms: [term] ) end end |
#to_file(filename) ⇒ Object
24 25 26 27 28 |
# File 'lib/osgeo/termbase/concept_collection.rb', line 24 def to_file(filename) File.open(filename,"w") do |file| file.write(to_hash.to_yaml) end end |
#to_hash ⇒ Object
18 19 20 21 22 |
# File 'lib/osgeo/termbase/concept_collection.rb', line 18 def to_hash self.inject({}) do |acc, (id, concept)| acc.merge!(id => concept.to_hash) end end |