module DocTemplate::Objects::MetadataHelpers

Constants

SEPARATOR

Public Class Methods

build_anchor_from(item) click to toggle source
# File lib/doc_template/objects/metadata_helpers.rb, line 8
def self.build_anchor_from(item)
  [
    item.idx,
    item.try(:template_type),
    item.try(:level),
    item.title
  ].compact.join('-').parameterize
end

Public Instance Methods

standard_info(standards) click to toggle source
# File lib/doc_template/objects/metadata_helpers.rb, line 17
def standard_info(standards)
  Array.wrap(standards)
    .flat_map { |x| x.to_s.split(SEPARATOR) }
    .map(&:strip)
    .reject(&:blank?)
    .uniq
    .map { |x| { description: Standard.search_by_name(x).take&.description, standard: x } }
end