Class: HtmlsToPdf
- Inherits:
-
Object
- Object
- HtmlsToPdf
- Defined in:
- lib/htmls_to_pdf/htmls_to_pdf.rb
Constant Summary collapse
- TMP_HTML_PREFIX =
'tmp_html_file_'- TMP_PDF_PREFIX =
'tmp_pdf_file_'
Instance Attribute Summary collapse
-
#cssarray ⇒ Object
readonly
Returns the value of attribute cssarray.
-
#htmlarray ⇒ Object
readonly
Returns the value of attribute htmlarray.
-
#pdfarray ⇒ Object
readonly
Returns the value of attribute pdfarray.
-
#remove_css_files ⇒ Object
readonly
Returns the value of attribute remove_css_files.
-
#remove_html_files ⇒ Object
readonly
Returns the value of attribute remove_html_files.
-
#remove_tmp_pdf_files ⇒ Object
readonly
Returns the value of attribute remove_tmp_pdf_files.
-
#savedir ⇒ Object
readonly
Returns the value of attribute savedir.
-
#savename ⇒ Object
readonly
Returns the value of attribute savename.
-
#urls ⇒ Object
readonly
Returns the value of attribute urls.
Instance Method Summary collapse
- #create_pdf ⇒ Object
-
#initialize(in_config = {}) ⇒ HtmlsToPdf
constructor
A new instance of HtmlsToPdf.
Constructor Details
#initialize(in_config = {}) ⇒ HtmlsToPdf
Returns a new instance of HtmlsToPdf.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 15 def initialize(in_config = {}) config = { :css => [], :remove_css_files => true, :remove_html_files => true, :remove_tmp_pdf_files => true, :overwrite_existing_pdf => false, :options => {}, :savedir => File.("~"), :savename => 'htmls_to_pdf.pdf' }.merge(in_config) set_dir(config[:savedir]) @savename = config[:savename] @overwrite_existing_pdf = config[:overwrite_existing_pdf] exit_if_pdf_exists unless @overwrite_existing_pdf @urls = clean_urls(config[:urls]) @pdfarray = create_pdfarray @cssarray = config[:css].kind_of?(Array) ? config[:css] : Array[ config[:css] ] @remove_css_files = config[:remove_css_files] @remove_html_files = config[:remove_html_files] @remove_tmp_pdf_files = config[:remove_tmp_pdf_files] @remove_css_files = @remove_html_files = @remove_tmp_pdf_files = true if in_config[:remove_temp_files] @options = config[:options] end |
Instance Attribute Details
#cssarray ⇒ Object (readonly)
Returns the value of attribute cssarray.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def cssarray @cssarray end |
#htmlarray ⇒ Object (readonly)
Returns the value of attribute htmlarray.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def htmlarray @htmlarray end |
#pdfarray ⇒ Object (readonly)
Returns the value of attribute pdfarray.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def pdfarray @pdfarray end |
#remove_css_files ⇒ Object (readonly)
Returns the value of attribute remove_css_files.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def remove_css_files @remove_css_files end |
#remove_html_files ⇒ Object (readonly)
Returns the value of attribute remove_html_files.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def remove_html_files @remove_html_files end |
#remove_tmp_pdf_files ⇒ Object (readonly)
Returns the value of attribute remove_tmp_pdf_files.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def remove_tmp_pdf_files @remove_tmp_pdf_files end |
#savedir ⇒ Object (readonly)
Returns the value of attribute savedir.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def savedir @savedir end |
#savename ⇒ Object (readonly)
Returns the value of attribute savename.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def savename @savename end |
#urls ⇒ Object (readonly)
Returns the value of attribute urls.
10 11 12 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 10 def urls @urls end |
Instance Method Details
#create_pdf ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 40 def create_pdf clean_temp_files download_files generate_pdfs join_pdfs clean_temp_files end |