Class: Dieses::Application::Pen::Draw
- Inherits:
-
Object
- Object
- Dieses::Application::Pen::Draw
- Extended by:
- Forwardable
- Defined in:
- lib/dieses/application/pen.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
- #call(&block) ⇒ Object
-
#initialize(pen, ruler, pos: Undefined) ⇒ Draw
constructor
A new instance of Draw.
- #repeat(count = nil, &block) ⇒ Object
Methods included from Movements
#cross, #down, #left, #move, #right, #up
Methods included from Elements
#cline, #hline, #rect, #square, #vline
Constructor Details
#initialize(pen, ruler, pos: Undefined) ⇒ Draw
Returns a new instance of Draw.
27 28 29 30 31 32 |
# File 'lib/dieses/application/pen.rb', line 27 def initialize(pen, ruler, pos: Undefined) @pen = pen @pos = Undefined.default(pos, Geometry::Point::Mutable.cast(canvas.position)) @ruler = ruler @buffer = Set.new end |
Class Method Details
Instance Method Details
#call(&block) ⇒ Object
48 49 50 51 |
# File 'lib/dieses/application/pen.rb', line 48 def call(&block) instance_exec(&block) put end |
#repeat(count = nil, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dieses/application/pen.rb', line 34 def repeat(count = nil, &block) self.class.new(pen, ruler, pos: pos.dup).instance_exec do 1.step(count) do prev = pos.dup instance_exec(&block) put break if pos == prev || perfect.outside?(pos) rescue Offsite break end end end |