Class: Kotoshu::Configuration::Builder
- Inherits:
-
Object
- Object
- Kotoshu::Configuration::Builder
- Defined in:
- lib/kotoshu/configuration/builder.rb
Overview
Builder for creating immutable Configuration objects.
Provides a fluent interface for building configuration objects that are frozen after creation, ensuring thread-safety and immutability.
Class Method Summary collapse
-
.build {|builder| ... } ⇒ Configuration
Build an immutable configuration.
Instance Method Summary collapse
-
#case_sensitive=(sensitive) ⇒ self
Set case sensitivity.
-
#custom_words=(words) ⇒ self
Set custom words.
-
#dictionary_path=(path) ⇒ self
Set dictionary path.
-
#dictionary_type=(type) ⇒ self
Set dictionary type.
-
#encoding=(encoding) ⇒ self
Set encoding.
-
#initialize ⇒ Builder
constructor
Create a new builder.
-
#language=(lang) ⇒ self
Set language code.
-
#locale=(locale) ⇒ self
Set locale.
-
#max_suggestions=(max) ⇒ self
Set max suggestions.
-
#suggestion_algorithms=(algorithms) ⇒ self
Set suggestion algorithms.
-
#to_config ⇒ Configuration
Convert builder to frozen Configuration.
-
#verbose=(verbose) ⇒ self
Set verbose mode.
-
#with_case_sensitive(sensitive) ⇒ Configuration
Fluent method to set case sensitivity.
-
#with_dictionary_path(path) ⇒ Configuration
Fluent method to set dictionary path.
-
#with_dictionary_type(type) ⇒ Configuration
Fluent method to set dictionary type.
-
#with_language(lang) ⇒ Configuration
Fluent method to set language.
-
#with_locale(locale) ⇒ Configuration
Fluent method to set locale.
-
#with_max_suggestions(max) ⇒ Configuration
Fluent method to set max suggestions.
-
#with_verbose(verbose) ⇒ Configuration
Fluent method to set verbose mode.
Constructor Details
Class Method Details
.build {|builder| ... } ⇒ Configuration
Build an immutable configuration.
35 36 37 38 39 |
# File 'lib/kotoshu/configuration/builder.rb', line 35 def self.build builder_instance = new yield(builder_instance) if block_given? builder_instance.to_config end |
Instance Method Details
#case_sensitive=(sensitive) ⇒ self
Set case sensitivity.
95 96 97 98 |
# File 'lib/kotoshu/configuration/builder.rb', line 95 def case_sensitive=(sensitive) @settings[:case_sensitive] = sensitive self end |
#custom_words=(words) ⇒ self
Set custom words.
122 123 124 125 |
# File 'lib/kotoshu/configuration/builder.rb', line 122 def custom_words=(words) @settings[:custom_words] = words.dup.freeze self end |
#dictionary_path=(path) ⇒ self
Set dictionary path.
50 51 52 53 |
# File 'lib/kotoshu/configuration/builder.rb', line 50 def dictionary_path=(path) @settings[:dictionary_path] = path self end |
#dictionary_type=(type) ⇒ self
Set dictionary type.
59 60 61 62 |
# File 'lib/kotoshu/configuration/builder.rb', line 59 def dictionary_type=(type) @settings[:dictionary_type] = type self end |
#encoding=(encoding) ⇒ self
Set encoding.
131 132 133 134 |
# File 'lib/kotoshu/configuration/builder.rb', line 131 def encoding=(encoding) @settings[:encoding] = encoding self end |
#language=(lang) ⇒ self
Set language code.
68 69 70 71 |
# File 'lib/kotoshu/configuration/builder.rb', line 68 def language=(lang) @settings[:language] = lang self end |
#locale=(locale) ⇒ self
Set locale.
77 78 79 80 |
# File 'lib/kotoshu/configuration/builder.rb', line 77 def locale=(locale) @settings[:locale] = locale self end |
#max_suggestions=(max) ⇒ self
Set max suggestions.
86 87 88 89 |
# File 'lib/kotoshu/configuration/builder.rb', line 86 def max_suggestions=(max) @settings[:max_suggestions] = max self end |
#suggestion_algorithms=(algorithms) ⇒ self
Set suggestion algorithms.
113 114 115 116 |
# File 'lib/kotoshu/configuration/builder.rb', line 113 def suggestion_algorithms=(algorithms) @settings[:suggestion_algorithms] = algorithms self end |
#to_config ⇒ Configuration
Convert builder to frozen Configuration.
202 203 204 205 206 |
# File 'lib/kotoshu/configuration/builder.rb', line 202 def to_config config = Configuration.new(@settings.dup) config.freeze config end |
#verbose=(verbose) ⇒ self
Set verbose mode.
104 105 106 107 |
# File 'lib/kotoshu/configuration/builder.rb', line 104 def verbose=(verbose) @settings[:verbose] = verbose self end |
#with_case_sensitive(sensitive) ⇒ Configuration
Fluent method to set case sensitivity.
185 186 187 188 |
# File 'lib/kotoshu/configuration/builder.rb', line 185 def with_case_sensitive(sensitive) @settings[:case_sensitive] = sensitive self end |
#with_dictionary_path(path) ⇒ Configuration
Fluent method to set dictionary path.
140 141 142 143 |
# File 'lib/kotoshu/configuration/builder.rb', line 140 def with_dictionary_path(path) @settings[:dictionary_path] = path self end |
#with_dictionary_type(type) ⇒ Configuration
Fluent method to set dictionary type.
149 150 151 152 |
# File 'lib/kotoshu/configuration/builder.rb', line 149 def with_dictionary_type(type) @settings[:dictionary_type] = type self end |
#with_language(lang) ⇒ Configuration
Fluent method to set language.
158 159 160 161 |
# File 'lib/kotoshu/configuration/builder.rb', line 158 def with_language(lang) @settings[:language] = lang self end |
#with_locale(locale) ⇒ Configuration
Fluent method to set locale.
167 168 169 170 |
# File 'lib/kotoshu/configuration/builder.rb', line 167 def with_locale(locale) @settings[:locale] = locale self end |
#with_max_suggestions(max) ⇒ Configuration
Fluent method to set max suggestions.
176 177 178 179 |
# File 'lib/kotoshu/configuration/builder.rb', line 176 def with_max_suggestions(max) @settings[:max_suggestions] = max self end |
#with_verbose(verbose) ⇒ Configuration
Fluent method to set verbose mode.
194 195 196 197 |
# File 'lib/kotoshu/configuration/builder.rb', line 194 def with_verbose(verbose) @settings[:verbose] = verbose self end |