Class: Source2Pdf::Exporter
- Inherits:
-
Object
- Object
- Source2Pdf::Exporter
- Defined in:
- lib/source2pdf/exporter.rb
Overview
rubocop:disable ClassLength, MethodLength
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
-
#exts ⇒ Object
readonly
Returns the value of attribute exts.
-
#non_exts ⇒ Object
readonly
Returns the value of attribute non_exts.
-
#output_name ⇒ Object
readonly
Returns the value of attribute output_name.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#repo_name ⇒ Object
readonly
Returns the value of attribute repo_name.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#export ⇒ Object
Print and export the source from a given URL to a pdf.
-
#initialize(url, opts = {}) ⇒ Exporter
constructor
The initializer for Exporter.
- #to_s ⇒ Object
Constructor Details
#initialize(url, opts = {}) ⇒ Exporter
The initializer for Exporter
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/source2pdf/exporter.rb', line 25 def initialize(url, opts = {}) @url = url @base_dir = Dir.pwd @exts = opts[:exts] || [] @non_exts = opts[:non_exts] || [] @theme = opts[:theme] || "default" @repo_name = project_name(url) @output_path = File.([base_dir, repo_name].join(File::SEPARATOR)) @output_name = pdf_filename(opts[:output_name]) || "#{@repo_name}.pdf" end |
Instance Attribute Details
#base_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
11 12 13 |
# File 'lib/source2pdf/exporter.rb', line 11 def base_dir @base_dir end |
#exts ⇒ Object (readonly)
Returns the value of attribute exts.
5 6 7 |
# File 'lib/source2pdf/exporter.rb', line 5 def exts @exts end |
#non_exts ⇒ Object (readonly)
Returns the value of attribute non_exts.
5 6 7 |
# File 'lib/source2pdf/exporter.rb', line 5 def non_exts @non_exts end |
#output_name ⇒ Object (readonly)
Returns the value of attribute output_name.
5 6 7 |
# File 'lib/source2pdf/exporter.rb', line 5 def output_name @output_name end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
11 12 13 |
# File 'lib/source2pdf/exporter.rb', line 11 def output_path @output_path end |
#repo_name ⇒ Object (readonly)
Returns the value of attribute repo_name.
11 12 13 |
# File 'lib/source2pdf/exporter.rb', line 11 def repo_name @repo_name end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
5 6 7 |
# File 'lib/source2pdf/exporter.rb', line 5 def theme @theme end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/source2pdf/exporter.rb', line 5 def url @url end |
Instance Method Details
#export ⇒ Object
Print and export the source from a given URL to a pdf
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/source2pdf/exporter.rb', line 37 def export clone puts "FYI: list of extensions: #{all_extensions}" puts "FYI: list of all files : #{all_files}" files2htmls htmls2pdfs pdfs2pdf copy_output cleanup end |
#to_s ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/source2pdf/exporter.rb', line 48 def to_s " url : \#{url}\n base_dir : \#{base_dir}\n exts : \#{exts}\n non_exts : \#{non_exts}\n repo_name : \#{repo_name}\n theme : \#{theme}\n output_path : \#{output_path}\n output_name : \#{output_name}\n EOT\nend\n" |