Class: Versionomy::Format::Delimiter::StringFieldBuilder

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(recognizers_, field_, default_opts_) ⇒ StringFieldBuilder

:nodoc:



557
558
559
560
561
# File 'lib/versionomy/format/delimiter.rb', line 557

def initialize(recognizers_, field_, default_opts_)  # :nodoc:
  @recognizers = recognizers_
  @field = field_
  @default_opts = default_opts_
end

Instance Method Details

#recognize_regexp(regexp_, opts_ = {}) ⇒ Object

Recognize a string field whose value matches a regular expression. The regular expression must be passed as a string. E.g. use "[a-z]+" instead of /[a-z]+/. Using the opts parameter, you can override any of the field's overall parsing options.



570
571
572
# File 'lib/versionomy/format/delimiter.rb', line 570

def recognize_regexp(regexp_, opts_={})
  @recognizers << Delimiter::RegexpStringRecognizer.new(@field, regexp_, @default_opts.merge(opts_))
end