Class: MonthlyCalendar
- Inherits:
-
Object
- Object
- MonthlyCalendar
- Includes:
- UI
- Defined in:
- lib/monthly_calendar.rb,
lib/monthly_calendar/version.rb
Constant Summary collapse
- VERSION =
"0.2.3"
Instance Attribute Summary collapse
-
#pdf ⇒ Object
readonly
Returns the value of attribute pdf.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MonthlyCalendar
constructor
A new instance of MonthlyCalendar.
- #save(file_name = "calendar.pdf") ⇒ Object
- #stream {|to_s| ... } ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ MonthlyCalendar
Returns a new instance of MonthlyCalendar.
12 13 14 15 16 17 18 19 |
# File 'lib/monthly_calendar.rb', line 12 def initialize( = {}) @start_date = ([:start_date] && Date.parse([:start_date])) || Date.today @pages_count = [:pages] || 1 @pdf = Prawn::Document.new(page_layout: :landscape, top_margin: 1.in, skip_page_creation: true) create end |
Instance Attribute Details
#pdf ⇒ Object (readonly)
Returns the value of attribute pdf.
10 11 12 |
# File 'lib/monthly_calendar.rb', line 10 def pdf @pdf end |
Instance Method Details
#save(file_name = "calendar.pdf") ⇒ Object
21 22 23 |
# File 'lib/monthly_calendar.rb', line 21 def save(file_name = "calendar.pdf") pdf.render_file File.(file_name) end |
#stream {|to_s| ... } ⇒ Object
25 26 27 |
# File 'lib/monthly_calendar.rb', line 25 def stream yield(to_s) end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/monthly_calendar.rb', line 29 def to_s pdf.render end |