class DocTemplate::Objects::SectionsMetadata

Public Class Methods

build_from(data, template_type) click to toggle source
# File lib/doc_template/objects/sections_metadata.rb, line 41
def self.build_from(data, template_type)
  copy = Marshal.load Marshal.dump(data)
  sections = copy.map do |metadata|
    metadata[:template_type] = template_type
    metadata[:summary] = DocTemplate.sanitizer.strip_html_element(metadata[:summary])
    metadata.transform_keys { |k| k.to_s.gsub('section-', '').underscore }
  end
  new(set_index(children: sections))
end

Public Instance Methods

add_break() click to toggle source
# File lib/doc_template/objects/sections_metadata.rb, line 51
def add_break
  idx = children.index { |c| !c.handled } || -1
  section = Section.new(title: 'Foundational Skills Lesson', anchor: 'optbreak', time: 0, children: [])
  children.insert(idx - 1, section)
end