Class: Spoonerize::Config
- Inherits:
-
Object
- Object
- Spoonerize::Config
- Defined in:
- lib/spoonerize/config.rb
Overview
Runtime options used by the CLI and Spoonerism instances.
Instance Attribute Summary collapse
-
#consonants_only ⇒ Boolean
When true, only consonant-starting words are eligible to be flipped.
-
#excluded_words ⇒ Array
Words that should not be altered.
-
#lazy ⇒ Boolean
Lazy mode.
-
#lazy_words ⇒ Array
Words to skip when
lazyis true. -
#logfile_name ⇒ String
Name of the log file.
-
#reverse ⇒ Boolean
When true, reverse the order of the flipping.
Instance Method Summary collapse
-
#initialize ⇒ Spoonerize::Config
constructor
Create instance of Config.
-
#with(**overrides) ⇒ Spoonerize::Config
Create a copy of the current config with optional overrides.
Constructor Details
#initialize ⇒ Spoonerize::Config
Create instance of Config.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/spoonerize/config.rb', line 48 def initialize @lazy = false @lazy_words = %w[i a an and in of the my your his her him hers to is] @excluded_words = [] @consonants_only = false @reverse = false @logfile_name = File.( File.join(ENV["HOME"], ".cache", "spoonerize", "spoonerize.csv") ) end |
Instance Attribute Details
#consonants_only ⇒ Boolean
When true, only consonant-starting words are eligible to be flipped.
29 30 31 |
# File 'lib/spoonerize/config.rb', line 29 def consonants_only @consonants_only end |
#excluded_words ⇒ Array
Words that should not be altered.
23 24 25 |
# File 'lib/spoonerize/config.rb', line 23 def excluded_words @excluded_words end |
#lazy ⇒ Boolean
Lazy mode. If true, words in lazy_words will not be altered.
11 12 13 |
# File 'lib/spoonerize/config.rb', line 11 def lazy @lazy end |
#lazy_words ⇒ Array
Words to skip when lazy is true.
17 18 19 |
# File 'lib/spoonerize/config.rb', line 17 def lazy_words @lazy_words end |
#logfile_name ⇒ String
Name of the log file. Should be a fully-qualified file path.
42 43 44 |
# File 'lib/spoonerize/config.rb', line 42 def logfile_name @logfile_name end |
#reverse ⇒ Boolean
When true, reverse the order of the flipping. Only makes a difference when there are more than two flip-able words.
36 37 38 |
# File 'lib/spoonerize/config.rb', line 36 def reverse @reverse end |
Instance Method Details
#with(**overrides) ⇒ Spoonerize::Config
Create a copy of the current config with optional overrides.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/spoonerize/config.rb', line 63 def with(**overrides) self.class.new.tap do |config| config.lazy = lazy config.lazy_words = lazy_words.dup config.excluded_words = excluded_words.dup config.consonants_only = consonants_only config.reverse = reverse config.logfile_name = logfile_name overrides.each do |key, value| config.public_send(:"#{key}=", copy_value(value)) end end end |