Class: TrelloScrum::Pdf
- Inherits:
-
Object
- Object
- TrelloScrum::Pdf
- Defined in:
- lib/pdf.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(page_size = 'A4', options = {}) ⇒ Pdf
constructor
A new instance of Pdf.
- #render_cards(cards) ⇒ Object
- #save(filename) ⇒ Object
Constructor Details
#initialize(page_size = 'A4', options = {}) ⇒ Pdf
Returns a new instance of Pdf.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pdf.rb', line 9 def initialize(page_size = 'A4', = {}) @options = { base_font_size: 20 }.update() @doc = Prawn::Document.new :page_size => page_size, :page_layout => :landscape self.doc.font_families.update("FontAwesome" => {:normal => "#{File.dirname(__FILE__)}/../resources/fontawesome-webfont.ttf"}) self.doc.font_families.update( "OpenSans" => { :normal => "#{File.dirname(__FILE__)}/../resources/OpenSans-Regular.ttf", :bold => "#{File.dirname(__FILE__)}/../resources/OpenSans-Bold.ttf", :bold_italic => "#{File.dirname(__FILE__)}/../resources/OpenSans-BoldItalic.ttf", :italic => "#{File.dirname(__FILE__)}/../resources/OpenSans-Italic.ttf" } ) self.doc.font "OpenSans", :size => self.[:base_font_size] end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
7 8 9 |
# File 'lib/pdf.rb', line 7 def doc @doc end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/pdf.rb', line 7 def @options end |
Instance Method Details
#render_cards(cards) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pdf.rb', line 33 def render_cards(cards) # Flatten the structure cards = cards.map{|list| list[:cards]}.flatten cards.each_with_index do |card, i| render_card(card) # Start next card on new page self.doc.start_new_page unless i == cards.size - 1 end end |
#save(filename) ⇒ Object
45 46 47 |
# File 'lib/pdf.rb', line 45 def save(filename) self.doc.render_file filename end |