Class: Versionomy::Conversion::Parsing::Builder
- Inherits:
-
Object
- Object
- Versionomy::Conversion::Parsing::Builder
- Includes:
- Blockenspiel::DSL
- Defined in:
- lib/versionomy/conversion/parsing.rb
Overview
Call methods of this class in the block passed to Versionomy::Conversion::Parsing#new to fine-tune the behavior of the converter.
Instance Method Summary (collapse)
-
- (Object) _get_original_value_modifier
:nodoc:.
-
- (Object) _get_parse_params_generator
:nodoc:.
-
- (Object) _get_string_modifier
:nodoc:.
-
- (Object) _get_unparse_params_modifier
:nodoc:.
-
- (Builder) initialize
constructor
:nodoc:.
-
- (Object) to_generate_parse_params(&block_)
Provide a block that generates the params used to parse the new value.
-
- (Object) to_modify_original_value(&block_)
Provide a block that can modify the original value prior to it being unparsed.
-
- (Object) to_modify_string(&block_)
Provide a block that can modify the unparsed string prior to it being passed to the parser.
-
- (Object) to_modify_unparse_params(&block_)
Provide a block that can modify the params used to unparse the old value.
Constructor Details
- (Builder) initialize
:nodoc:
117 118 119 120 121 122 |
# File 'lib/versionomy/conversion/parsing.rb', line 117 def initialize # :nodoc: @original_value_modifier = nil @string_modifier = nil @parse_params_generator = nil @unparse_params_modifier = nil end |
Instance Method Details
- (Object) _get_original_value_modifier
:nodoc:
173 174 175 |
# File 'lib/versionomy/conversion/parsing.rb', line 173 def _get_original_value_modifier # :nodoc: @original_value_modifier end |
- (Object) _get_parse_params_generator
:nodoc:
185 186 187 |
# File 'lib/versionomy/conversion/parsing.rb', line 185 def _get_parse_params_generator # :nodoc: @parse_params_generator end |
- (Object) _get_string_modifier
:nodoc:
177 178 179 |
# File 'lib/versionomy/conversion/parsing.rb', line 177 def _get_string_modifier # :nodoc: @string_modifier end |
- (Object) _get_unparse_params_modifier
:nodoc:
181 182 183 |
# File 'lib/versionomy/conversion/parsing.rb', line 181 def _get_unparse_params_modifier # :nodoc: @unparse_params_modifier end |
- (Object) to_generate_parse_params(&block_)
Provide a block that generates the params used to parse the new value. The block should take one parameter, the convert_params passed to convert_value (which may be nil). It should return the parse params that should be used.
130 131 132 |
# File 'lib/versionomy/conversion/parsing.rb', line 130 def to_generate_parse_params(&block_) @parse_params_generator = block_ end |
- (Object) to_modify_original_value(&block_)
Provide a block that can modify the original value prior to it being unparsed. The block should take two parameters: first, the original value to be converted, and second, the convert_params passed to convert_value (which may be nil). It should return the value to be unparsed, which may be the same as the value originally passed in. This method may fail-fast by raising a Versionomy::Errors::ConversionError if it determines that the value passed in cannot be converted as is.
156 157 158 |
# File 'lib/versionomy/conversion/parsing.rb', line 156 def to_modify_original_value(&block_) @original_value_modifier = block_ end |
- (Object) to_modify_string(&block_)
Provide a block that can modify the unparsed string prior to it being passed to the parser. The block should take two parameters: first, the string resulting from unparsing the old value, and second, the convert_params passed to convert_value (which may be nil). It should return the string to be parsed to get the new value.
168 169 170 |
# File 'lib/versionomy/conversion/parsing.rb', line 168 def to_modify_string(&block_) @string_modifier = block_ end |
- (Object) to_modify_unparse_params(&block_)
Provide a block that can modify the params used to unparse the old value. The block should take two parameters: first, the original unparse params from the old value (which may be nil), and second, the convert_params passed to convert_value (which may also be nil). It should return the unparse params that should actually be used.
142 143 144 |
# File 'lib/versionomy/conversion/parsing.rb', line 142 def to_modify_unparse_params(&block_) @unparse_params_modifier = block_ end |