Class: Defmastership::Modifier::UpdateIrefChecksum::Helper::IrefReplacementFormatterChecksum

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(match_data, document) ⇒ IrefReplacementFormatterChecksum

Returns a new instance of IrefReplacementFormatterChecksum.

Parameters:

  • match_data (MatchData)

    of the ref statement

  • document (Document)

    the overall parsed document



38
39
40
# File 'lib/defmastership/modifier/update_iref_checksum.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
# File 'lib/defmastership/modifier/update_iref_checksum.rb', line 43

def to_s
  return match_data unless definition

  "defs:iref[#{reference_string}(#{match_data[:explicit_version]}#{definition.sha256_short})]"
end