Class: Clamsy::BasePrinter
- Inherits:
-
Object
- Object
- Clamsy::BasePrinter
- Extended by:
- FileSystemSupport
- Defined in:
- lib/clamsy/base_printer.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.subclasses ⇒ Object
readonly
Returns the value of attribute subclasses.
Class Method Summary collapse
Methods included from FileSystemSupport
file_must_exist!, tmp_file, trash_tmp_files
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/clamsy/base_printer.rb', line 12 def config @config end |
.subclasses ⇒ Object (readonly)
Returns the value of attribute subclasses.
12 13 14 |
# File 'lib/clamsy/base_printer.rb', line 12 def subclasses @subclasses end |
Class Method Details
.docs_to_pdf(from_docs, to_pdf) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/clamsy/base_printer.rb', line 14 def docs_to_pdf(from_docs, to_pdf) begin tmp_ps = tmp_file(File.basename(to_pdf, '.pdf')) from_docs.map {|doc| tmp_ps << doc_to_ps_stream(doc.path) } tmp_ps.close gs_convert(:pdf, tmp_ps.path, to_pdf) ensure trash_tmp_files end end |
.get(name, config) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/clamsy/base_printer.rb', line 25 def get(name, config) begin require File.join(File.dirname(__FILE__), "#{name}_printer.rb") printer = self.subclasses[name.gsub(/[^a-zA-Z0-9]/,'').downcase] printer.configure(config) ; printer rescue Exception raise PrinterNotFoundError.new("Printer '#{name}' cannot be found.") end end |