Class: Proforma::HtmlRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/proforma/html_renderer.rb,
lib/proforma/html_renderer/writer.rb,
lib/proforma/html_renderer/version.rb,
lib/proforma/html_renderer/object_writer.rb,
lib/proforma/html_renderer/proforma_writer.rb

Overview

This main class to use as a Proforma renderer.

Defined Under Namespace

Classes: ObjectWriter, ProformaWriter, Writer

Constant Summary collapse

EXTENSION =
'.html'
DEFAULT_OPTIONS =
{
  bold_weight: 'bold',
  font_family: 'sans-serif',
  header_font_size: 18,
  line_height_increase: 5,
  text_font_size: 13
}.freeze
VERSION =
'1.0.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HtmlRenderer

Returns a new instance of HtmlRenderer.



33
34
35
# File 'lib/proforma/html_renderer.rb', line 33

def initialize(options = {})
  @options = OpenStruct.new(DEFAULT_OPTIONS.merge(options))
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



31
32
33
# File 'lib/proforma/html_renderer.rb', line 31

def options
  @options
end

Instance Method Details

#render(prototype) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/proforma/html_renderer.rb', line 37

def render(prototype)
  contents = ProformaWriter.render(prototype, options)

  Proforma::Document.new(
    contents: contents,
    extension: EXTENSION,
    title: prototype.title
  )
end