Class: LittleWeasel::Configuration
- Inherits:
-
Object
- Object
- LittleWeasel::Configuration
- Defined in:
- lib/LittleWeasel/configure.rb
Overview
This class encapsulates the configuration properties for this gem and provides methods and attributes that allow for management of the same.
attr_reader :max_dictionary_file_megabytes, :max_invalid_words_bytesize, :metadata_observers
Instance Attribute Summary collapse
-
#max_dictionary_file_megabytes ⇒ Object
Returns the value of attribute max_dictionary_file_megabytes.
-
#max_invalid_words_bytesize ⇒ Object
Returns the value of attribute max_invalid_words_bytesize.
-
#metadata_observers ⇒ Object
Returns the value of attribute metadata_observers.
-
#word_block_regex ⇒ Object
Returns the value of attribute word_block_regex.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
The constructor; calls #reset.
-
#max_dictionary_file_bytes ⇒ Integer
Returns the maximum consumable dictionary size in bytes.
-
#max_invalid_words_bytesize? ⇒ true, false
If #max_invalid_words_bytesize is > 0, true will be returned; false otherwise.
-
#reset ⇒ void
Resets the configuration settings to their default values.
Constructor Details
#initialize ⇒ Configuration
The constructor; calls #reset.
30 31 32 |
# File 'lib/LittleWeasel/configure.rb', line 30 def initialize reset end |
Instance Attribute Details
#max_dictionary_file_megabytes ⇒ Object
Returns the value of attribute max_dictionary_file_megabytes.
26 27 28 |
# File 'lib/LittleWeasel/configure.rb', line 26 def max_dictionary_file_megabytes @max_dictionary_file_megabytes end |
#max_invalid_words_bytesize ⇒ Object
Returns the value of attribute max_invalid_words_bytesize.
26 27 28 |
# File 'lib/LittleWeasel/configure.rb', line 26 def max_invalid_words_bytesize @max_invalid_words_bytesize end |
#metadata_observers ⇒ Object
Returns the value of attribute metadata_observers.
26 27 28 |
# File 'lib/LittleWeasel/configure.rb', line 26 def @metadata_observers end |
#word_block_regex ⇒ Object
Returns the value of attribute word_block_regex.
26 27 28 |
# File 'lib/LittleWeasel/configure.rb', line 26 def word_block_regex @word_block_regex end |
Instance Method Details
#max_dictionary_file_bytes ⇒ Integer
Returns the maximum consumable dictionary size in bytes. Dictionaries larger than #max_dictionary_file_bytes will raise an error.
The default is 5 megabytes.
56 57 58 |
# File 'lib/LittleWeasel/configure.rb', line 56 def max_dictionary_file_bytes @max_dictionary_file_megabytes * 1_000_000 end |
#max_invalid_words_bytesize? ⇒ true, false
If #max_invalid_words_bytesize is > 0, true will be returned; false otherwise.
64 65 66 |
# File 'lib/LittleWeasel/configure.rb', line 64 def max_invalid_words_bytesize? max_invalid_words_bytesize.positive? end |
#reset ⇒ void
This method returns an undefined value.
Resets the configuration settings to their default values.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/LittleWeasel/configure.rb', line 37 def reset @max_dictionary_file_megabytes = 5 @max_invalid_words_bytesize = 25_000 @metadata_observers = [ LittleWeasel::Metadata::InvalidWordsMetadata ] # TODO: Is this the correct regex to use, or is there something better? # @word_block_regex = /\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/ # @word_block_regex = /(?:(?:[\-A-Za-z0-9]|\d(?!\d|\b))+(?:'[\-A-Za-z0-9]+)?)/ # @word_block_regex = /(?:(?:[\-a-z0-9]|\d(?!\d|\b))+(?:'[\-a-z0-9]+)?)/i @word_block_regex = /[[[:word:]]'-]+/ end |