Class: Bookwatch::Subnav::TemplateCreator
- Inherits:
-
Object
- Object
- Bookwatch::Subnav::TemplateCreator
- Defined in:
- lib/bookwatch/subnav/template_creator.rb
Defined Under Namespace
Classes: LinkHolder
Instance Attribute Summary collapse
-
#fs ⇒ Object
readonly
Returns the value of attribute fs.
-
#html_doc_manipulator ⇒ Object
readonly
Returns the value of attribute html_doc_manipulator.
-
#output_locations ⇒ Object
readonly
Returns the value of attribute output_locations.
Instance Method Summary collapse
- #create(navigation_entries, subnav_spec) ⇒ Object
-
#initialize(fs, output_locations) ⇒ TemplateCreator
constructor
A new instance of TemplateCreator.
Constructor Details
#initialize(fs, output_locations) ⇒ TemplateCreator
Returns a new instance of TemplateCreator.
7 8 9 10 |
# File 'lib/bookwatch/subnav/template_creator.rb', line 7 def initialize(fs, output_locations) @fs = fs @output_locations = output_locations end |
Instance Attribute Details
#fs ⇒ Object (readonly)
Returns the value of attribute fs.
21 22 23 |
# File 'lib/bookwatch/subnav/template_creator.rb', line 21 def fs @fs end |
#html_doc_manipulator ⇒ Object (readonly)
Returns the value of attribute html_doc_manipulator.
21 22 23 |
# File 'lib/bookwatch/subnav/template_creator.rb', line 21 def html_doc_manipulator @html_doc_manipulator end |
#output_locations ⇒ Object (readonly)
Returns the value of attribute output_locations.
21 22 23 |
# File 'lib/bookwatch/subnav/template_creator.rb', line 21 def output_locations @output_locations end |
Instance Method Details
#create(navigation_entries, subnav_spec) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/bookwatch/subnav/template_creator.rb', line 12 def create(, ) template_content = fs.read(template_path) links_template = ERB.new(fs.read(.join('_nav-links.erb'))) populated_nav = ERB.new(template_content).result(LinkHolder.new(, links_template).get_binding) fs.write(text: populated_nav, to: (.)) end |