Class: Versionomy::Format::Delimiter::RegexpSymbolRecognizer

Inherits:
RecognizerBase
  • Object
show all
Defined in:
lib/versionomy/format/delimiter.rb

Overview

A recognizer for symbolic fields that recognizes a single regular expression and maps it to a single particular value.

Instance Method Summary collapse

Methods inherited from RecognizerBase

#parse, #requires_next_field, #setup, #unparse

Constructor Details

#initialize(field_, value_, regexp_, canonical_, opts_ = {}) ⇒ RegexpSymbolRecognizer

:nodoc:



986
987
988
989
990
# File 'lib/versionomy/format/delimiter.rb', line 986

def initialize(field_, value_, regexp_, canonical_, opts_={})
  setup(field_, regexp_, opts_)
  @value = value_
  @canonical = canonical_
end

Instance Method Details

#parsed_value(value_, parse_params_) ⇒ Object



992
993
994
# File 'lib/versionomy/format/delimiter.rb', line 992

def parsed_value(value_, parse_params_)
  [@value, nil]
end

#should_unparse?(value_, style_) ⇒ Boolean

Returns:

  • (Boolean)


1000
1001
1002
# File 'lib/versionomy/format/delimiter.rb', line 1000

def should_unparse?(value_, style_)
  style_ == @style && value_ == @value
end

#unparsed_value(value_, style_, unparse_params_) ⇒ Object



996
997
998
# File 'lib/versionomy/format/delimiter.rb', line 996

def unparsed_value(value_, style_, unparse_params_)
  @canonical
end