class Versionomy::Format::Delimiter::SymbolFieldBuilder

This class defines methods that can be called from the block passed to Versionomy::Format::Delimiter::Builder#field if the field is of symbolic type.

Public Instance Methods

recognize_regexp(value_, regexp_, canonical_, opts_={}, &block_) click to toggle source

Recognize a symbolic value represented by a particular regular expression. The regular expression must be passed as a string. E.g. use “[a-z]+” instead of /[a-z]+/. The “canonical” parameter indicates the canonical syntax for the value, for use in unparsing.

Using the opts parameter, you can override any of the field's overall parsing options.

# File lib/versionomy/format/delimiter.rb, line 601
def recognize_regexp(value_, regexp_, canonical_, opts_={}, &block_)
  @recognizers << Delimiter::RegexpSymbolRecognizer.new(@field, value_, regexp_, canonical_, @default_opts.merge(opts_))
end
recognize_regexp_map(opts_={}, &block_) click to toggle source

Recognize a set of symbolic values, each represented by a particular regular expression, but all sharing the same delimiters and options. Use this instead of repeated calls to #recognize_regexp for better performance.

Using the opts parameter, you can override any of the field's overall parsing options.

In the block, you should call methods of Versionomy::Format::Delimiter::MappingSymbolBuilder to map values to regular expression representations.

# File lib/versionomy/format/delimiter.rb, line 618
def recognize_regexp_map(opts_={}, &block_)
  @recognizers << Delimiter::MappingSymbolRecognizer.new(@field, @default_opts.merge(opts_), &block_)
end