Class: Bookbinder::Subnav::JsonFromMarkdownToc

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fs) ⇒ JsonFromMarkdownToc

Returns a new instance of JsonFromMarkdownToc.



8
9
10
11
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 8

def initialize(fs)
  @fs = fs
  @renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



20
21
22
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 20

def config
  @config
end

#fsObject (readonly)

Returns the value of attribute fs.



20
21
22
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 20

def fs
  @fs
end

#rendererObject (readonly)

Returns the value of attribute renderer.



20
21
22
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 20

def renderer
  @renderer
end

#source_for_site_genObject (readonly)

Returns the value of attribute source_for_site_gen.



20
21
22
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 20

def source_for_site_gen
  @source_for_site_gen
end

Instance Method Details



13
14
15
16
17
18
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 13

def get_links(subnav_config, output_locations)
  @source_for_site_gen = output_locations.source_for_site_generator
  @config = subnav_config

  { links: get_links_and_headers }.to_json
end