Class: ConvertToPDF
- Inherits:
-
Object
- Object
- ConvertToPDF
- Defined in:
- lib/code2pdf/convert_to_pdf.rb
Constant Summary collapse
- PDF_OPTIONS =
{ page_size: 'A4' }.freeze
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ ConvertToPDF
constructor
A new instance of ConvertToPDF.
Constructor Details
#initialize(params = {}) ⇒ ConvertToPDF
Returns a new instance of ConvertToPDF.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/code2pdf/convert_to_pdf.rb', line 6 def initialize(params = {}) if !params.key?(:from) || params[:from].nil? raise ArgumentError.new 'where is the codebase you want to convert to PDF?' elsif !valid_directory?(params[:from]) raise LoadError.new "#{params[:from]} not found" elsif !params.key?(:to) || params[:to].nil? raise ArgumentError.new 'where should I save the generated pdf file?' else @from, @to, @except = params[:from], params[:to], params[:except].to_s if File.exist?(@except) && invalid_blacklist? raise LoadError.new "#{@except} is not a valid blacklist YAML file" end save end end |