Class: Angus::SDoc::Definitions::Glossary

Inherits:
Object
  • Object
show all
Defined in:
lib/angus/definitions/glossary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(terms_hash = {}) ⇒ Glossary

Initializes a new Glossary and its terms.

Examples:


{'Glossary Term Name' =>
  {
    'long_name'   => 'Long name of the glossary term',
    'description' => 'Description of the glossary term'
  }
}

Parameters:

  • terms_hash (Hash<String, Hash>) (defaults to: {})

    The hash contains GlossaryTerm#short_name as the key and a hash containing GlossaryTerm#long_name and GlossaryTerm#description as a value.



22
23
24
# File 'lib/angus/definitions/glossary.rb', line 22

def initialize(terms_hash = {})
  @terms = Angus::SDoc::Definitions::GlossaryTerm.build_from_hash(terms_hash)
end

Instance Attribute Details

#termsGlossaryTerm

Returns The terms of the glossary.

Returns:



7
8
9
# File 'lib/angus/definitions/glossary.rb', line 7

def terms
  @terms
end

Instance Method Details

#terms_hashHash<String, GlossaryTerm>

Returns a hash with short name as key and the term as the value.

Returns:



29
30
31
32
33
34
35
36
37
# File 'lib/angus/definitions/glossary.rb', line 29

def terms_hash
  hash = {}

  @terms.each do |term|
    hash[term.short_name] = term
  end

  hash
end

#terms_hash_with_long_namesHash<String, GlossaryTerm>

Returns a hash with long name as key and the term as the value.

Returns:



42
43
44
45
46
47
48
# File 'lib/angus/definitions/glossary.rb', line 42

def terms_hash_with_long_names
  hash = {}
  @terms.each do |term|
    hash[term.long_name] = term
  end
  hash
end