class Bookbinder::Subnav::PdfConfigCreator
Attributes
fs[R]
output_locations[R]
Public Class Methods
new(fs, output_locations)
click to toggle source
# File lib/bookbinder/subnav/pdf_config_creator.rb, line 6 def initialize(fs, output_locations) @fs = fs @output_locations = output_locations end
Public Instance Methods
create(navigation_entries, subnav_config)
click to toggle source
# File lib/bookbinder/subnav/pdf_config_creator.rb, line 11 def create(navigation_entries, subnav_config) @links = format_links(navigation_entries) fs.overwrite(to: output_locations.pdf_config_dir.join(subnav_config.pdf_config), text: config_content) end
Private Instance Methods
config_content()
click to toggle source
# File lib/bookbinder/subnav/pdf_config_creator.rb, line 30 def config_content config_keys.inject({}) do |hash, key| hash[key] = content_for(key) hash end.to_yaml end
config_keys()
click to toggle source
# File lib/bookbinder/subnav/pdf_config_creator.rb, line 37 def config_keys %w{copyright_notice header executable pages} end
content_for(key)
click to toggle source
# File lib/bookbinder/subnav/pdf_config_creator.rb, line 41 def content_for(key) key == 'pages' ? @links : default_content end
default_content()
click to toggle source
# File lib/bookbinder/subnav/pdf_config_creator.rb, line 45 def default_content 'REPLACE ME' end
format_links(links)
click to toggle source
# File lib/bookbinder/subnav/pdf_config_creator.rb, line 26 def format_links(links) links.map{|item| item[:url] }.compact.map{|link| link.sub(/^\//, '')} end
props_location(filename)
click to toggle source
# File lib/bookbinder/subnav/pdf_config_creator.rb, line 22 def props_location(filename) output_locations.subnavs_for_layout_dir.join(filename) end