Class: DocPdf
- Inherits:
-
Object
- Object
- DocPdf
- Defined in:
- lib/doc_2_pdf/doc_pdf.rb
Class Method Summary collapse
- .configure(**opts) ⇒ Object
- .convert! ⇒ Object
- .convert_single!(doc) ⇒ Object
- .doc?(file_path) ⇒ Boolean
Class Method Details
.configure(**opts) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/doc_2_pdf/doc_pdf.rb', line 2 def self.configure **opts [:doc_dir, :pdf_dir].each do |required_opt| raise ArgumentError, "Missing required config option: :#{required_opt}" unless opts[required_opt] end @@doc_dir = File.join(opts[:doc_dir], '') # adds trailing '/' if it doesn't already have one @@pdf_dir = File.join(opts[:pdf_dir], '') # adds trailing '/' if it doesn't already have one end |
.convert! ⇒ Object
10 11 12 13 14 15 |
# File 'lib/doc_2_pdf/doc_pdf.rb', line 10 def self.convert! Dir.glob(File.join(@@doc_dir, '**', '*.{doc,docx}')) do |doc| relative_pdf_path = convert_doc doc yield(relative_pdf_path) if block_given? end end |
.convert_single!(doc) ⇒ Object
17 18 19 |
# File 'lib/doc_2_pdf/doc_pdf.rb', line 17 def self.convert_single! doc convert_doc doc end |
.doc?(file_path) ⇒ Boolean
21 22 23 |
# File 'lib/doc_2_pdf/doc_pdf.rb', line 21 def self.doc? file_path ['.doc', '.docx'].include? File.extname(file_path) end |