Class: MonthlyCalendar

Inherits:
Object
  • Object
show all
Includes:
UI
Defined in:
lib/monthly_calendar.rb,
lib/monthly_calendar/version.rb

Constant Summary collapse

VERSION =
"0.2.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @start_date = (options[:start_date] && Date.parse(options[:start_date])) ||
                Date.today
  @pages_count = options[:pages] || 1

  @pdf = Prawn::Document.new(page_layout: :landscape, top_margin: 1.in, skip_page_creation: true)
  create
end

Instance Attribute Details

#pdfObject (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.expand_path(file_name)
end

#stream {|to_s| ... } ⇒ Object

Yields:



25
26
27
# File 'lib/monthly_calendar.rb', line 25

def stream
  yield(to_s)
end

#to_sObject



29
30
31
# File 'lib/monthly_calendar.rb', line 29

def to_s
  pdf.render
end