Class: Laser::Cutter::Renderer::MetaRenderer
- Defined in:
- lib/laser-cutter/renderer/meta_renderer.rb
Constant Summary collapse
- META_KEYS =
%w(units width height depth thickness notch kerf stroke padding margin page_size page_layout)
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#config, #enclosure, #page_manager, #subject
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ MetaRenderer
constructor
A new instance of MetaRenderer.
- #render(pdf = nil) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(config = {}) ⇒ MetaRenderer
Returns a new instance of MetaRenderer.
6 7 8 9 |
# File 'lib/laser-cutter/renderer/meta_renderer.rb', line 6 def initialize(config = {}) self.config = config self.enclosure = Laser::Cutter::Geometry::Rect.create(Laser::Cutter::Geometry::Point[1, 1], 140, 150) end |
Instance Method Details
#render(pdf = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/laser-cutter/renderer/meta_renderer.rb', line 11 def render pdf = nil = <<-EOF Made with Laser Cutter Ruby Gem (v#{Laser::Cutter::VERSION}) Credits to Prawn for ruby PDF generation, and BoxMaker for inspiration. Online: http://makeabox.io/ Source: https://github.com/kigster/laser-cutter EOF = BLUE = 55 = config.to_hash ['page_size'] ||= 'custom' .delete('page_layout') if ['page_size'].eql?('custom') = META_KEYS.find_all{|k| [k]}.join(": \n") + ": \n" = META_KEYS.find_all{|k| [k]}.map{|k| [k] }.join("\n") rect = self.enclosure pdf.instance_eval do self.line_width = 0.2.mm float do bounding_box([rect.p1.x, rect.h + rect.p1.y], :width => rect.w, :height => rect.h) do stroke_color stroke_bounds # Print banner indent 10 do font('Helvetica', :size => 6) do text , :color => end end # print values of the config, in two parts – keys right aligned first, values left aligned second. float do bounding_box([0, rect.h - ], :width => rect.w, :height => rect.h - ) do float do bounding_box([0, rect.h - ], :width => 70, :height => rect.h - ) do indent 10 do font('Helvetica', :size => 7) do text , :color => , align: :right end end end end float do bounding_box([60, rect.h - ], :width => 70, :height => rect.h - ) do indent 10 do font('Helvetica', :size => 7) do text , :color => end end end end end end end end end end |