Module: DocTemplate::Objects::MetadataHelpers

Included in:
ActivityMetadata::Activity, SectionsMetadata::Section
Defined in:
lib/doc_template/objects/metadata_helpers.rb

Constant Summary collapse

SEPARATOR =
/\s*[,;]\s*/.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build_anchor_from(item) ⇒ Object



8
9
10
11
12
13
14
15
# 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

Instance Method Details

#standard_info(standards) ⇒ Object



17
18
19
20
21
22
23
24
# 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