Class: DocTemplate::Objects::SectionsMetadata

Inherits:
Object
  • Object
show all
Includes:
TocHelpers
Defined in:
lib/doc_template/objects/sections_metadata.rb

Defined Under Namespace

Classes: Section

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TocHelpers

#find_by_anchor, #level1_by_title, #level2_by_title

Class Method Details

.build_from(data, template_type) ⇒ Object



41
42
43
44
45
46
47
48
49
# 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 ||
    [:template_type] = template_type
    [:summary] = DocTemplate.sanitizer.strip_html_element([:summary])
    .transform_keys { |k| k.to_s.gsub('section-', '').underscore }
  end
  new(set_index(children: sections))
end

Instance Method Details

#add_breakObject



51
52
53
54
55
# 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