Module: Howdy::Dictionary

Defined in:
lib/howdy/base.rb,
lib/howdy/dictionaries/dict_pl.rb,
lib/howdy/dictionaries/ling_pl.rb,
lib/howdy/dictionaries/dictionary_com.rb,
lib/howdy/dictionaries/urban_dictionary_com.rb

Overview

Howdy::Dictionary exposes accessors of dictionaries collection.

Defined Under Namespace

Classes: Base, DictPl, DictionaryCom, LingPl, UrbanDictionaryCom

Class Method Summary collapse

Class Method Details

.availableObject

Returns array of available dictionaries



34
35
36
# File 'lib/howdy/base.rb', line 34

def self.available
  @@available_dictionaries ||= []
end

.configObject



13
14
15
# File 'lib/howdy/base.rb', line 13

def self.config
  @@config ||= Config.new.parse
end

.currentObject

Returns current dictionary class



18
19
20
# File 'lib/howdy/base.rb', line 18

def self.current
  @@dictionary ||= default
end

.defaultObject

Returns default dictionary



29
30
31
# File 'lib/howdy/base.rb', line 29

def self.default
  @@default ||= (find_by_label(config[:default_dictionary]) || DictionaryCom)
end

.find_by_label(label) ⇒ Object

Find dictionary class by label



44
45
46
# File 'lib/howdy/base.rb', line 44

def self.find_by_label(label)
  available.detect { |dict| dict.dict_label == label.to_s }
end

.range_availableObject

Returns range from 1 to total dictionaries count (1..Dictionary.available.size)



39
40
41
# File 'lib/howdy/base.rb', line 39

def self.range_available
  (1..available.size)
end

.set(dictionary) ⇒ Object

Set current dictionary. Pass a class as an argument

Howdy::Dictionary.set(DictionaryCom)


24
25
26
# File 'lib/howdy/base.rb', line 24

def self.set(dictionary)
  @@dictionary = dictionary
end