class Danger::Toc::Extractor

Public Class Methods

new(root, options) click to toggle source
Calls superclass method
# File lib/toc/extractor.rb, line 6
def initialize(root, options)
  super
  @toc_start = nil
  @toc_end = nil
  @in_toc = false
end

Public Instance Methods

convert(el) click to toggle source
# File lib/toc/extractor.rb, line 13
def convert(el)
  if el.type == :header && el.options[:raw_text] == Danger::Toc.config.header
    @in_toc = true
    @toc_start = el.options[:location]
  elsif el.type == :header
    @toc_end = el.options[:location] if @in_toc && !@toc_end
    @in_toc = false
  else
    el.children.each { |child| convert(child) }
  end
  [@toc_start, @toc_end]
end