Class: Versionomy::Format::Delimiter::IntegerFieldBuilder

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 integer type.

Instance Method Summary collapse

Constructor Details

#initialize(recognizers_, field_, default_opts_) ⇒ IntegerFieldBuilder

:nodoc:



505
506
507
508
509
# File 'lib/versionomy/format/delimiter.rb', line 505

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

Instance Method Details

#recognize_letter(opts_ = {}) ⇒ Object

Recognize a letter-formatted integer field. That is, the value is formatted as an alphabetic letter where ā€œaā€ represents 1, up to ā€œzā€ representing 26.

Using the opts parameter, you can override any of the field's overall parsing options. You may also set the following additional options:

:case

Case-sensitivity of the letter. Possible values are :upper, :lower, and :either. Default is :either.



542
543
544
# File 'lib/versionomy/format/delimiter.rb', line 542

def recognize_letter(opts_={})
  @recognizers << Delimiter::AlphabeticIntegerRecognizer.new(@field, @default_opts.merge(opts_))
end

#recognize_number(opts_ = {}) ⇒ Object

Recognize a numeric-formatted integer field. Using the opts parameter, you can override any of the field's overall parsing options. You may also set the following additional options:

:strip_leading_zeros

If false (the default), and a value has leading zeros, it is assumed that the field has a minimum width, and unparsing will always pad left with zeros to reach that minimum width. If set to true, leading zeros are stripped from a value, and this padding is never done.



524
525
526
# File 'lib/versionomy/format/delimiter.rb', line 524

def recognize_number(opts_={})
  @recognizers << Delimiter::BasicIntegerRecognizer.new(@field, @default_opts.merge(opts_))
end