Class: Versionomy::Format::Delimiter::MappingSymbolBuilder

Inherits:
Object
  • Object
show all
Includes:
Blockenspiel::DSL
Defined in:
lib/versionomy/format/delimiter.rb

Overview

Methods in this class can be called from the block passed to Versionomy::Format::Delimiter::SymbolFieldBuilder#recognize_regexp_map to define the mapping between the values of a symbolic field and the string representations of those values.

Instance Method Summary collapse

Constructor Details

#initialize(mappings_in_order_, mappings_by_value_) ⇒ MappingSymbolBuilder

:nodoc:



634
635
636
637
# File 'lib/versionomy/format/delimiter.rb', line 634

def initialize(mappings_in_order_, mappings_by_value_)  # :nodoc:
  @mappings_in_order = mappings_in_order_
  @mappings_by_value = mappings_by_value_
end

Instance Method Details

#map(value_, representation_, regexp_ = nil) ⇒ Object

Map a value to a string representation. The optional regexp field, if specified, provides a regular expression pattern for matching the value representation. If it is omitted, the representation is used as the regexp.



645
646
647
648
649
650
# File 'lib/versionomy/format/delimiter.rb', line 645

def map(value_, representation_, regexp_=nil)
  regexp_ ||= representation_
  array_ = [regexp_, representation_, value_]
  @mappings_by_value[value_] ||= array_
  @mappings_in_order << array_
end