class DocTemplate::Objects::TOCMetadata::Heading
Public Instance Methods
excluded?(excludes, ela: false)
click to toggle source
# File lib/doc_template/objects/toc_metadata.rb, line 21 def excluded?(excludes, ela: false) # Do not exclude parent if all children are optional and deselected return false if ela && children.all?(&:optional) return excludes.exclude?(anchor) if optional return true if excludes.include?(anchor) children.any? && children.all? { |c| c.excluded?(excludes) } end
time_with(excludes)
click to toggle source
# File lib/doc_template/objects/toc_metadata.rb, line 30 def time_with(excludes) # rubocop:disable Metrics/PerceivedComplexity # Optional and nothing to exclude explicitly return excludes.include?(anchor) ? time : 0 if optional # General and excluded explicitly return 0 if excludes.include?(anchor) # do not re-caclculate time if # - there are no optional children # - no excludes passed # - there are no children at all if children.any?(&:optional) children.sum { |c| c.time_with(excludes) } elsif children.blank? || excludes.blank? time else children.sum { |c| c.time_with(excludes) } end end