Class: Asciidoctor::Defmastership::Preprocessor::Helper::DefinitionStringBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor-defmastership/preprocessor.rb

Overview

Isolate the definition macro

Instance Method Summary collapse

Constructor Details

#initialize(match, show_explicit_checksum) ⇒ DefinitionStringBuilder

Returns a new instance of DefinitionStringBuilder.

Parameters:

  • match (MatchData)

    match data from defintion Regexp

  • show_explicit_checksum (Boolean)

    sepcify if we need to show checksums in rendered document



191
192
193
194
# File 'lib/asciidoctor-defmastership/preprocessor.rb', line 191

def initialize(match, show_explicit_checksum)
  @match = match
  @show_explicit_checksum = show_explicit_checksum
end

Instance Method Details

#str_aArray<String>

Returns the lines to replace defininition’s line.

Returns:

  • (Array<String>)

    the lines to replace defininition’s line



197
198
199
200
201
202
203
204
205
206
# File 'lib/asciidoctor-defmastership/preprocessor.rb', line 197

def str_a
  explicit_checksum_str = " [.checksum]#(#{@match[:explicit_checksum]})#" if @show_explicit_checksum
  explicit_version_str = Helper.explicit_version_str(@match[:explicit_version])
  labels_str = Helper.labels_str(@match[:labels])
  reference = @match[:reference]
  [
    ".#{reference}#{explicit_version_str}#{explicit_checksum_str}#{labels_str}",
    "[##{reference}.define.#{@match[:type]}]"
  ]
end