Class: Opus
- Inherits:
-
Object
- Object
- Opus
- Defined in:
- lib/opus.rb,
lib/opus/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#column_count ⇒ Object
The number of columns per page.
-
#font_family ⇒ Object
The font family to use.
-
#font_size ⇒ Object
The font size to use.
-
#page_layout ⇒ Object
The page layout to use (portrait, landscape).
Instance Method Summary collapse
-
#generate(filenames, output) ⇒ Object
Generates a PDF from a list of source files.
-
#initialize ⇒ Opus
constructor
Creates a new opus instance.
Constructor Details
#initialize ⇒ Opus
Creates a new opus instance.
8 9 10 11 12 13 |
# File 'lib/opus.rb', line 8 def initialize() self.page_layout = :landscape self.column_count = 5 self.font_family = "Courier" self.font_size = 4 end |
Instance Attribute Details
#column_count ⇒ Object
The number of columns per page.
16 17 18 |
# File 'lib/opus.rb', line 16 def column_count @column_count end |
#font_family ⇒ Object
The font family to use.
19 20 21 |
# File 'lib/opus.rb', line 19 def font_family @font_family end |
#font_size ⇒ Object
The font size to use.
22 23 24 |
# File 'lib/opus.rb', line 22 def font_size @font_size end |
#page_layout ⇒ Object
The page layout to use (portrait, landscape).
25 26 27 |
# File 'lib/opus.rb', line 25 def page_layout @page_layout end |
Instance Method Details
#generate(filenames, output) ⇒ Object
Generates a PDF from a list of source files.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/opus.rb', line 31 def generate(filenames, output) column_count = self.column_count font_family = self.font_family font_size = self.font_size # Columnize lines in PDF. Prawn::Document.generate(output, page_layout: page_layout) do font(font_family, :size => font_size) do column_box([0, cursor], :columns => column_count, :width => bounds.width) do filenames.each do |filename| content = IO.read(filename).gsub(/^/, ". ") text("<b>#{filename}</b>", inline_format: true) text(content) text("\n\n") end end end end end |