module TeachingPrintables::QuadRulable
Creates quadrille rulings on paper. Delegates Prawn methods to Prawn::Document.
Attributes
rule_unit[RW]
Make quadrille rules
Public Instance Methods
create_quad_rule(options={})
click to toggle source
# File lib/teaching_printables/quad_rulable.rb, line 21 def create_quad_rule(options={}) parse_options(options) puts rule_unit ncols = (rule_width.to_f/rule_unit).ceil nrows = (rule_height.to_f/rule_unit).ceil #Create svg grid with 10pxX10px unit square. #str = SVGComponents::header(@width,@height) str = SVGComponents::quad_ruled_grid(nrows,ncols) #str << SVGComponents::footer if (page_number ==0) || (options[:start_new_page] == true) start_new_page end svg(str,width: ncols*rule_unit, height: nrows*rule_unit, at:[0,rule_height]) #position: :center, vposition: :center) end
rule_height()
click to toggle source
# File lib/teaching_printables/quad_rulable.rb, line 14 def rule_height bounds.top - bounds.bottom end
rule_width()
click to toggle source
# File lib/teaching_printables/quad_rulable.rb, line 17 def rule_width bounds.right - bounds.left end
Private Instance Methods
parse_options(options)
click to toggle source
# File lib/teaching_printables/quad_rulable.rb, line 42 def parse_options(options) allowed_parameters = [:rule_unit] options.each do |k,v| puts "@#{k.to_s}" instance_variable_set("@#{k.to_s}",v) if allowed_parameters.include?(k) end end