Class: Availability::Renderer
- Inherits:
-
Object
- Object
- Availability::Renderer
- Defined in:
- lib/availability/renderer.rb
Overview
Renders calculated availability into a self-contained static HTML page.
Defined Under Namespace
Classes: View
Constant Summary collapse
- ROBOTS =
"User-agent: *\nDisallow: /\n"
Instance Method Summary collapse
-
#initialize(template_path:) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(days:, generated_at:, timezone:, enabled:, today:, days_to_show:, first_day_of_week:) ⇒ Object
Constructor Details
#initialize(template_path:) ⇒ Renderer
Returns a new instance of Renderer.
12 13 14 |
# File 'lib/availability/renderer.rb', line 12 def initialize(template_path:) @template = ERB.new(File.read(template_path), trim_mode: '-') end |
Instance Method Details
#render(days:, generated_at:, timezone:, enabled:, today:, days_to_show:, first_day_of_week:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/availability/renderer.rb', line 16 def render(days:, generated_at:, timezone:, enabled:, today:, days_to_show:, first_day_of_week:) view = View.new( days: days, generated_at: generated_at, timezone: timezone, enabled: enabled, today: today, days_to_show: days_to_show, first_day_of_week: first_day_of_week ) @template.result(view.template_binding) end |