Class: Pandocomatic::Printer
- Inherits:
-
Object
- Object
- Pandocomatic::Printer
- Defined in:
- lib/pandocomatic/printer/printer.rb
Overview
Printer base class for printing information from pandocomatic
Direct Known Subclasses
CommandPrinter, ConfigurationErrorsPrinter, ErrorPrinter, HelpPrinter, SummaryPrinter, UnknownErrorPrinter, VersionPrinter, WarningPrinter
Instance Method Summary collapse
-
#initialize(template_file = 'help.txt') ⇒ Printer
constructor
Create a new Printer.
-
#print ⇒ Object
Print to STDOUT.
-
#template(template_file) ⇒ Object
Set the template used by this Printer.
-
#to_s ⇒ String
Create a string based on this printer’s template.
Constructor Details
#initialize(template_file = 'help.txt') ⇒ Printer
Create a new Printer
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 ⇒ Object
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
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_s ⇒ String
Create a string based on this printer’s template
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 |