Class: Aquanaut::Sitemap
- Inherits:
-
Object
- Object
- Aquanaut::Sitemap
- Defined in:
- lib/aquanaut/sitemap.rb
Overview
The sitemap class is used to render the results in HTML and JavaScript.
Uses SLIM as a template engine.
Instance Method Summary collapse
-
#initialize(graph, domain, target_dir = "#{Dir.pwd}/sitemap") ⇒ Sitemap
constructor
A new instance of Sitemap.
-
#render_results ⇒ Object
Renders the results by initiailizing the dependencies and processingt the template.
Constructor Details
#initialize(graph, domain, target_dir = "#{Dir.pwd}/sitemap") ⇒ Sitemap
Returns a new instance of Sitemap.
10 11 12 13 14 15 16 17 18 |
# File 'lib/aquanaut/sitemap.rb', line 10 def initialize(graph, domain, target_dir="#{Dir.pwd}/sitemap") @graph = graph @domain = domain @target_dir = target_dir if Pathname.new(target_dir).relative? @target_dir = File.("../../../#{target_dir}", __FILE__) end end |
Instance Method Details
#render_results ⇒ Object
Renders the results by initiailizing the dependencies and processingt the template.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aquanaut/sitemap.rb', line 22 def render_results initialize_target_directory = { disable_escape: true } template_path = File.('../templates/index.html.slim', __FILE__) rendered_template = Slim::Template.new(template_path, ).render(self) File.open("#{@target_dir}/index.html", 'w') do |file| file.write rendered_template end end |