class Angus::SDoc::Definitions::Glossary

Attributes

terms[RW]

@!attribute [rw] terms

@return [GlossaryTerm] The terms of the glossary.

Public Class Methods

new(terms_hash = {}) click to toggle source

Initializes a new Glossary and its terms.

@param [Hash<String, Hash>] terms_hash The hash contains GlossaryTerm#short_name as the key

and a hash containing GlossaryTerm#long_name and GlossaryTerm#description as a value.

@example

{'Glossary Term Name' =>
  {
    'long_name'   => 'Long name of the glossary term',
    'description' => 'Description of the glossary term'
  }
}
# File lib/angus/definitions/glossary.rb, line 22
def initialize(terms_hash = {})
  @terms = Angus::SDoc::Definitions::GlossaryTerm.build_from_hash(terms_hash)
end

Public Instance Methods

terms_hash() click to toggle source

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

@return [Hash<String, GlossaryTerm>]

# 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_names() click to toggle source

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

@return [Hash<String, GlossaryTerm>]

# 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