Class: Defmastership::Modifier::UpdateIrefVersion::Helper::IrefReplacementFormatterVersion

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(match_data, document) ⇒ IrefReplacementFormatterVersion

Returns a new instance of IrefReplacementFormatterVersion.

Parameters:

  • match_data (MatchData)

    of the ref statement

  • document (Document)

    the overall parsed document



38
39
40
# File 'lib/defmastership/modifier/update_iref_version.rb', line 38

def initialize(match_data, document)
  super(match_data, document, :intref)
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.



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/defmastership/modifier/update_iref_version.rb', line 43

def to_s
  return match_data unless definition

  explicit_version = definition.explicit_version
  explicit_checksum = match_data[:explicit_checksum]

  if explicit_version || explicit_checksum
    "defs:iref[#{reference_string}(#{explicit_version}#{explicit_checksum})]"
  else
    "defs:iref[#{reference_string}]"
  end
end