Class: Pandocomatic::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/pandocomatic/printer/printer.rb

Overview

Printer base class for printing information from pandocomatic

Instance Method Summary collapse

Constructor Details

#initialize(template_file = 'help.txt') ⇒ Printer

Create a new Printer

Parameters:

  • template_file (String = 'help.txt') (defaults to: 'help.txt')

    the template to use when printing.



30
31
32
# File 'lib/pandocomatic/printer/printer.rb', line 30

def initialize(template_file = 'help.txt')
  template template_file
end

Instance Method Details

Print to STDOUT



51
52
53
54
# File 'lib/pandocomatic/printer/printer.rb', line 51

def print
  Pandocomatic::LOG.info self
  puts self
end

#template(template_file) ⇒ Object

Set the template used by this Printer

Parameters:

  • template_file (String)

    the template to use



37
38
39
40
# File 'lib/pandocomatic/printer/printer.rb', line 37

def template(template_file)
  dir = File.dirname(__FILE__)
  @template = File.absolute_path(File.join(dir, 'views', template_file))
end

#to_sString

Create a string based on this printer’s template

Returns:

  • (String)


45
46
47
48
# File 'lib/pandocomatic/printer/printer.rb', line 45

def to_s
  erb = ERB.new(File.read(@template), trim_mode: '>')
  erb.result(binding)
end