Class: Merimee::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/merimee/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



21
22
23
24
25
26
# File 'lib/merimee/config.rb', line 21

def initialize
  @dictionary = []
  @ignore_types = Merimee::DEFAULT_IGNORE_TYPES
  @api_key = Config.generate_api_key
  @language = Merimee::DEFAULT_LANGUAGE
end

Instance Attribute Details

#api_keyObject

This is required by the service for caching purposes, but no registration is needed (api_key should just be unique for your app, only one request can happen per key at any moment). There shouldn’t be any need for this, but still



15
16
17
# File 'lib/merimee/config.rb', line 15

def api_key
  @api_key
end

#dictionaryObject (readonly)

Returns the value of attribute dictionary.



8
9
10
# File 'lib/merimee/config.rb', line 8

def dictionary
  @dictionary
end

#ignore_typesObject

Returns the value of attribute ignore_types.



9
10
11
# File 'lib/merimee/config.rb', line 9

def ignore_types
  @ignore_types
end

#languageObject

The language to use for this check This is used to select the proper AtD server, unless overriden with the :language option



19
20
21
# File 'lib/merimee/config.rb', line 19

def language
  @language
end

Instance Method Details

#dict_add(word) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/merimee/config.rb', line 28

def dict_add(word)
  if word.kind_of?(String)
    @dictionary << word
  elsif word.kind_of?(Enumerable)
    @dictionary.concat word
  end
end

#dict_add_file(file) ⇒ Object



36
37
38
# File 'lib/merimee/config.rb', line 36

def dict_add_file(file)
  File.open(file) {|f| dict_add(f.readlines.map(&:strip)) }
end