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.
33 34 35 36 37 |
# File 'lib/kotoshu/configuration/builder.rb', line 33 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.
93 94 95 96 |
# File 'lib/kotoshu/configuration/builder.rb', line 93 def case_sensitive=(sensitive) @settings[:case_sensitive] = sensitive self end |
#custom_words=(words) ⇒ self
Set custom words.
120 121 122 123 |
# File 'lib/kotoshu/configuration/builder.rb', line 120 def custom_words=(words) @settings[:custom_words] = words.dup.freeze self end |
#dictionary_path=(path) ⇒ self
Set dictionary path.
48 49 50 51 |
# File 'lib/kotoshu/configuration/builder.rb', line 48 def dictionary_path=(path) @settings[:dictionary_path] = path self end |
#dictionary_type=(type) ⇒ self
Set dictionary type.
57 58 59 60 |
# File 'lib/kotoshu/configuration/builder.rb', line 57 def dictionary_type=(type) @settings[:dictionary_type] = type self end |
#encoding=(encoding) ⇒ self
Set encoding.
129 130 131 132 |
# File 'lib/kotoshu/configuration/builder.rb', line 129 def encoding=(encoding) @settings[:encoding] = encoding self end |
#language=(lang) ⇒ self
Set language code.
66 67 68 69 |
# File 'lib/kotoshu/configuration/builder.rb', line 66 def language=(lang) @settings[:language] = lang self end |
#locale=(locale) ⇒ self
Set locale.
75 76 77 78 |
# File 'lib/kotoshu/configuration/builder.rb', line 75 def locale=(locale) @settings[:locale] = locale self end |
#max_suggestions=(max) ⇒ self
Set max suggestions.
84 85 86 87 |
# File 'lib/kotoshu/configuration/builder.rb', line 84 def max_suggestions=(max) @settings[:max_suggestions] = max self end |
#suggestion_algorithms=(algorithms) ⇒ self
Set suggestion algorithms.
111 112 113 114 |
# File 'lib/kotoshu/configuration/builder.rb', line 111 def suggestion_algorithms=(algorithms) @settings[:suggestion_algorithms] = algorithms self end |
#to_config ⇒ Configuration
Convert builder to frozen Configuration.
200 201 202 203 204 |
# File 'lib/kotoshu/configuration/builder.rb', line 200 def to_config config = Configuration.new(@settings.dup) config.freeze config end |
#verbose=(verbose) ⇒ self
Set verbose mode.
102 103 104 105 |
# File 'lib/kotoshu/configuration/builder.rb', line 102 def verbose=(verbose) @settings[:verbose] = verbose self end |
#with_case_sensitive(sensitive) ⇒ Configuration
Fluent method to set case sensitivity.
183 184 185 186 |
# File 'lib/kotoshu/configuration/builder.rb', line 183 def with_case_sensitive(sensitive) @settings[:case_sensitive] = sensitive self end |
#with_dictionary_path(path) ⇒ Configuration
Fluent method to set dictionary path.
138 139 140 141 |
# File 'lib/kotoshu/configuration/builder.rb', line 138 def with_dictionary_path(path) @settings[:dictionary_path] = path self end |
#with_dictionary_type(type) ⇒ Configuration
Fluent method to set dictionary type.
147 148 149 150 |
# File 'lib/kotoshu/configuration/builder.rb', line 147 def with_dictionary_type(type) @settings[:dictionary_type] = type self end |
#with_language(lang) ⇒ Configuration
Fluent method to set language.
156 157 158 159 |
# File 'lib/kotoshu/configuration/builder.rb', line 156 def with_language(lang) @settings[:language] = lang self end |
#with_locale(locale) ⇒ Configuration
Fluent method to set locale.
165 166 167 168 |
# File 'lib/kotoshu/configuration/builder.rb', line 165 def with_locale(locale) @settings[:locale] = locale self end |
#with_max_suggestions(max) ⇒ Configuration
Fluent method to set max suggestions.
174 175 176 177 |
# File 'lib/kotoshu/configuration/builder.rb', line 174 def with_max_suggestions(max) @settings[:max_suggestions] = max self end |
#with_verbose(verbose) ⇒ Configuration
Fluent method to set verbose mode.
192 193 194 195 |
# File 'lib/kotoshu/configuration/builder.rb', line 192 def with_verbose(verbose) @settings[:verbose] = verbose self end |