Class: Bookbinder::Subnav::JsonFromHtmlToc

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/subnav/json_from_html_toc.rb

Instance Method Summary collapse

Constructor Details

#initialize(fs) ⇒ JsonFromHtmlToc

Returns a new instance of JsonFromHtmlToc.



7
8
9
# File 'lib/bookbinder/subnav/json_from_html_toc.rb', line 7

def initialize(fs)
  @fs = fs
end

Instance Method Details



11
12
13
14
15
16
17
18
19
20
# File 'lib/bookbinder/subnav/json_from_html_toc.rb', line 11

def get_links(section, output_locations)
  @section, @output_locations = section, output_locations

  doc = parse_toc_file
  set_anchor_values(doc.css('a'))

  {
    links: gather_urls_and_texts(doc.css('body > ul'))
  }.to_json
end