Class: Spoonerize::Config
- Inherits:
-
Object
- Object
- Spoonerize::Config
- Defined in:
- lib/spoonerize/config.rb
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.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/spoonerize/config.rb', line 46 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.
27 28 29 |
# File 'lib/spoonerize/config.rb', line 27 def consonants_only @consonants_only end |
#excluded_words ⇒ Array
Words that should not be altered.
21 22 23 |
# File 'lib/spoonerize/config.rb', line 21 def excluded_words @excluded_words end |
#lazy ⇒ Boolean
Lazy mode. If true, words in lazy_words will not be altered.
9 10 11 |
# File 'lib/spoonerize/config.rb', line 9 def lazy @lazy end |
#lazy_words ⇒ Array
Words to skip when lazy is true.
15 16 17 |
# File 'lib/spoonerize/config.rb', line 15 def lazy_words @lazy_words end |
#logfile_name ⇒ String
Name of the log file. Should be a fully-qualified file path.
40 41 42 |
# File 'lib/spoonerize/config.rb', line 40 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.
34 35 36 |
# File 'lib/spoonerize/config.rb', line 34 def reverse @reverse end |
Instance Method Details
#with(**overrides) ⇒ Spoonerize::Config
Create a copy of the current config with optional overrides.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/spoonerize/config.rb', line 61 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 |