Class: Bookbinder::Subnav::TemplateCreator
- Inherits:
-
Object
- Object
- Bookbinder::Subnav::TemplateCreator
- Defined in:
- lib/bookbinder/subnav/template_creator.rb
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(props_filename, subnav_spec) ⇒ Object
-
#initialize(fs, output_locations, html_doc_manipulator) ⇒ TemplateCreator
constructor
A new instance of TemplateCreator.
Constructor Details
#initialize(fs, output_locations, html_doc_manipulator) ⇒ TemplateCreator
Returns a new instance of TemplateCreator.
8 9 10 11 12 |
# File 'lib/bookbinder/subnav/template_creator.rb', line 8 def initialize(fs, output_locations, html_doc_manipulator) @fs = fs @output_locations = output_locations @html_doc_manipulator = html_doc_manipulator end |
Instance Attribute Details
#fs ⇒ Object (readonly)
Returns the value of attribute fs.
28 29 30 |
# File 'lib/bookbinder/subnav/template_creator.rb', line 28 def fs @fs end |
#html_doc_manipulator ⇒ Object (readonly)
Returns the value of attribute html_doc_manipulator.
28 29 30 |
# File 'lib/bookbinder/subnav/template_creator.rb', line 28 def html_doc_manipulator @html_doc_manipulator end |
#output_locations ⇒ Object (readonly)
Returns the value of attribute output_locations.
28 29 30 |
# File 'lib/bookbinder/subnav/template_creator.rb', line 28 def output_locations @output_locations end |
Instance Method Details
#create(props_filename, subnav_spec) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bookbinder/subnav/template_creator.rb', line 14 def create(props_filename, ) template_content = fs.read(template_path) nav_with_props = html_doc_manipulator.set_attribute(document: template_content, selector: 'div.nav-content', attribute: 'data-props-location', value: props_filename) nav_content = html_doc_manipulator.add_class(document: nav_with_props, selector: 'div.nav-content', classname: nav_type()) fs.write(text: nav_content, to: (.)) end |