Class: Choosy::Printing::ERBPrinter
- Inherits:
-
HelpPrinter
- Object
- BasePrinter
- HelpPrinter
- Choosy::Printing::ERBPrinter
- Defined in:
- lib/choosy/printing/erb_printer.rb
Constant Summary
Constants included from Terminal
Terminal::DEFAULT_COLUMN_COUNT, Terminal::DEFAULT_LINE_COUNT
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Attributes inherited from HelpPrinter
Attributes inherited from BasePrinter
#formatting_options, #heading_styles, #indent, #offset, #option_styles
Attributes included from Terminal
Instance Method Summary collapse
- #erb_binding ⇒ Object
-
#initialize(options) ⇒ ERBPrinter
constructor
A new instance of ERBPrinter.
- #print!(command) ⇒ Object
Methods inherited from HelpPrinter
#format_command, #format_element, #format_epilogue, #format_header, #format_option, #format_prologue
Methods inherited from BasePrinter
#command_name, #format!, #format_command, #format_element, #format_epilogue, #format_option, #format_prologue, #line_count, #regular_option, #usage_option, #usage_wrapped
Methods included from Terminal
#color, #command_exists?, die, #die, #page, #pager, #pager?, #pipe_in, #pipe_out, #stdin?, #unformatted
Constructor Details
#initialize(options) ⇒ ERBPrinter
Returns a new instance of ERBPrinter.
7 8 9 10 11 12 13 14 15 |
# File 'lib/choosy/printing/erb_printer.rb', line 7 def initialize() super() if [:template].nil? raise Choosy::ConfigurationError.new("no template file given to ERBPrinter") elsif !File.file?([:template]) raise Choosy::ConfigurationError.new("the template file doesn't exist: #{[:template]}") end @template = [:template] end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/choosy/printing/erb_printer.rb', line 5 def command @command end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
5 6 7 |
# File 'lib/choosy/printing/erb_printer.rb', line 5 def template @template end |
Instance Method Details
#erb_binding ⇒ Object
26 27 28 |
# File 'lib/choosy/printing/erb_printer.rb', line 26 def erb_binding binding end |
#print!(command) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/choosy/printing/erb_printer.rb', line 17 def print!(command) @command = command contents = nil File.open(template, 'r') {|f| contents = f.read } erb = ERB.new contents erb.result(self) end |