Class: Defmastership::Modifier::UpdateErefVersion::Helper::ErefReplacementFormatterVersion

Inherits:
ReplacementFormatter
  • Object
show all
Defined in:
lib/defmastership/modifier/update_eref_version.rb

Overview

A small, single-purpose class to format the eref replacement string.

Instance Method Summary collapse

Constructor Details

#initialize(match_data, document) ⇒ ErefReplacementFormatterVersion

Returns a new instance of ErefReplacementFormatterVersion.

Parameters:

  • match_data (MatchData)

    of the ref statement

  • document (Document)

    the overall parsed document



30
31
32
# File 'lib/defmastership/modifier/update_eref_version.rb', line 30

def initialize(match_data, document)
  super(match_data, document, :reference)
end

Instance Method Details

#to_sString

Returns the formatted string or the original match if no definition is found.

Returns:

  • (String)

    the formatted string or the original match if no definition is found.



35
36
37
38
39
40
41
# File 'lib/defmastership/modifier/update_eref_version.rb', line 35

def to_s
  version = definition ? definition.explicit_version : match_data[:explicit_version]
  checksum = match_data[:explicit_checksum]
  return reference_string unless version || checksum

  "#{reference_string}(#{version}#{checksum})"
end