Class: DocTemplate::Objects::AgendaMetadata
- Inherits:
-
Object
- Object
- DocTemplate::Objects::AgendaMetadata
- Includes:
- TocHelpers
- Defined in:
- lib/doc_template/objects/agenda_metadata.rb
Defined Under Namespace
Classes: Group, MetaCognition, MetaData, Section
Class Method Summary collapse
-
.build_from(data) ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Summary collapse
Methods included from TocHelpers
#find_by_anchor, #level1_by_title, #level2_by_title
Class Method Details
.build_from(data) ⇒ Object
rubocop:disable Metrics/AbcSize
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/doc_template/objects/agenda_metadata.rb', line 65 def self.build_from(data) # rubocop:disable Metrics/AbcSize copy = Marshal.load Marshal.dump(data) agenda_data = copy.map do |d| d[:children].each do |s| m = s[:metadata] s[:icons] = m['icons'] s[:material_ids] = m['material_ids'] s[:priority] = m['priority'] m['time'] = m['time'].to_s[/\d+/].to_i || 0 # Use color unless `no` is stated explicitly s[:use_color] = m['color'].present? ? !m['color'].casecmp('no').zero? : true s[:deselectable] = m['deselectable'].present? ? m['deselectable'].casecmp('yes').zero? : true s[:optional] = m['optional']&.casecmp('optional')&.zero? end d[:material_ids] = d[:metadata]['material_ids'] d.deep_merge(metadata: { time: d[:children].sum { |s| s[:metadata]['time'] } }) end new(set_index(children: agenda_data)) end |
Instance Method Details
#add_break ⇒ Object
86 87 88 89 90 |
# File 'lib/doc_template/objects/agenda_metadata.rb', line 86 def add_break idx = children.index { |c| !c.handled } || -1 group = Group.new title: '45 Minute Mark', anchor: 'optbreak', time: 0, children: [] children.insert(idx, group) end |