Class: Laser::Cutter::Renderer::Base
- Inherits:
-
Object
- Object
- Laser::Cutter::Renderer::Base
- Defined in:
- lib/laser/cutter/renderer/base.rb
Overview
The base of every renderer: it holds the settings and the thing it draws, its subject.
Direct Known Subclasses
BoxRenderer, LayoutRenderer, LineRenderer, MetaRenderer, RectRenderer, SvgRenderer
Constant Summary collapse
- BLACK =
The color of the lines to cut.
"000000"- BLUE =
The color of the settings block.
"0070E0"
Instance Attribute Summary collapse
-
#config ⇒ Configuration
The settings.
-
#enclosure ⇒ Geometry::Rect?
The rectangle around what is drawn.
-
#page_manager ⇒ PageManager
Converts PDF points into the units of the settings.
-
#subject ⇒ Object?
What is drawn: a box, a line or a rectangle.
Instance Method Summary collapse
-
#document ⇒ String
The document, yielding after each line drawn.
-
#initialize(config, subject = nil) ⇒ Base
constructor
A new instance of Base.
-
#render {|line| ... } ⇒ Integer
Writes the document to config.file, yielding after each line drawn.
-
#units ⇒ Symbol
:in or :mm.
Constructor Details
#initialize(config, subject = nil) ⇒ Base
Returns a new instance of Base.
26 27 28 29 30 |
# File 'lib/laser/cutter/renderer/base.rb', line 26 def initialize(config, subject = nil) self.config = config self.subject = subject self.page_manager = Laser::Cutter::PageManager.new(config.units) end |
Instance Attribute Details
#config ⇒ Configuration
Returns the settings.
22 23 24 |
# File 'lib/laser/cutter/renderer/base.rb', line 22 def config @config end |
#enclosure ⇒ Geometry::Rect?
Returns the rectangle around what is drawn.
22 |
# File 'lib/laser/cutter/renderer/base.rb', line 22 attr_accessor :config, :subject, :enclosure, :page_manager |
#page_manager ⇒ PageManager
Returns converts PDF points into the units of the settings.
22 |
# File 'lib/laser/cutter/renderer/base.rb', line 22 attr_accessor :config, :subject, :enclosure, :page_manager |
#subject ⇒ Object?
Returns what is drawn: a box, a line or a rectangle.
22 |
# File 'lib/laser/cutter/renderer/base.rb', line 22 attr_accessor :config, :subject, :enclosure, :page_manager |
Instance Method Details
#document ⇒ String
Returns the document, yielding after each line drawn.
42 43 44 |
# File 'lib/laser/cutter/renderer/base.rb', line 42 def document raise 'Abstract method' end |
#render {|line| ... } ⇒ Integer
Writes the document to config.file, yielding after each line drawn.
36 37 38 |
# File 'lib/laser/cutter/renderer/base.rb', line 36 def render(&) File.binwrite(config.file, document(&)) end |
#units ⇒ Symbol
Returns :in or :mm.
47 48 49 |
# File 'lib/laser/cutter/renderer/base.rb', line 47 def units config.units.to_sym end |