class TeachingPrintables::TPDocument

Creates quadrille rulings on paper. Delegates Prawn methods to Prawn::Document.

Constants

DOC_OPTIONS_DEFAULT

Public Class Methods

new(args={}) click to toggle source
# File lib/teaching_printables/tp_document.rb, line 13
def initialize(args={})
  args = DOC_OPTIONS_DEFAULT.merge(args).merge({skip_page_creation: true})
  @document = Prawn::Document.new(args)
end

Public Instance Methods

method_missing(m, *args) click to toggle source
Calls superclass method
# File lib/teaching_printables/tp_document.rb, line 34
def method_missing(m, *args)
  method = m.to_s
  if document.class.public_method_defined?(method)
    document.send(method,*args)
  elsif method.start_with?("page_")
    page_method = method[5..-1]
    if state.page.class.public_method_defined?(page_method)
      state.page.send(page_method,*args)
    else 
      raise NoMethodError.new("Can't find method",page_method)
    end
  else
    super
  end
end
page_height() click to toggle source
# File lib/teaching_printables/tp_document.rb, line 26
def page_height
  if page_layout == :portrait
    height = PDF::Core::PageGeometry::SIZES[page_size][1]
  else
    height = PDF::Core::PageGeometry::SIZES[page_size][0]
  end
end
page_width() click to toggle source
# File lib/teaching_printables/tp_document.rb, line 18
def page_width
  if page_layout == :portrait
    width = PDF::Core::PageGeometry::SIZES[page_size][0]
  else
    width = PDF::Core::PageGeometry::SIZES[page_size][1]
  end
end