-
-
Save sahidursuman/9092554f2c15d7aef9fa9fe40807c729 to your computer and use it in GitHub Desktop.
Object Oriented Prawn Report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prawn' | |
module Reports | |
class PrawnReport < Reports::Report | |
#call this from irb or any ruby code for that matter (i.e. Reports::PrawnReport.generate) | |
def self.generate | |
Prawn::Document.generate('prawn.pdf') do |pdf| | |
report_header(pdf) | |
report_body(pdf) | |
end | |
end | |
private | |
#place all pices of the report here | |
def self.report_header(pdf) | |
pdf.text 'Prawn Report' | |
end | |
def self.report_body(pdf) | |
pdf.text 'Report Body' | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Reports | |
class Report | |
#place share report methods here to share among multiple reports | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment