class Stepmod::Utils::Converters::ModuleRef

Public Instance Methods

convert(node, _state = {}) click to toggle source
# File lib/stepmod/utils/converters/module_ref.rb, line 7
def convert(node, _state = {})
  ref = node["linkend"]
  # #23:
  # In this case when we see this:

  # <module_ref linkend="product_as_individual:3_definition">individual products</module_ref>
  # We take the text value of the element and convert to this:

  # {{individual products}}

  ref = node.text.strip
  if !ref.empty?
    " {{#{normalized_ref(ref)}}} "
  elsif
    ref = node["linkend"].split(":").first
    " *#{ref}*"
  end
end

Private Instance Methods

normalized_ref(ref) click to toggle source
# File lib/stepmod/utils/converters/module_ref.rb, line 28
def normalized_ref(ref)
  return unless ref || ref.empty?

  ref.squeeze(" ").strip
end