Class: MarkovTextGenerator::Api::Model::Knowledge::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/markov_text_generator/api/model/knowledge/registry.rb

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry



6
7
8
# File 'lib/markov_text_generator/api/model/knowledge/registry.rb', line 6

def initialize
  @registry = {}
end

Instance Method Details

#[](key) ⇒ Object



19
20
21
# File 'lib/markov_text_generator/api/model/knowledge/registry.rb', line 19

def [](key)
  @registry.fetch key
end

#add_new_entry(key) ⇒ Object



10
11
12
13
# File 'lib/markov_text_generator/api/model/knowledge/registry.rb', line 10

def add_new_entry(key)
  @registry[key] ||= Entry.new key
  @registry[key]
end

#clear!Object



15
16
17
# File 'lib/markov_text_generator/api/model/knowledge/registry.rb', line 15

def clear!
  @registry.clear
end