Class: DYI::Shape::Path::CommandBase
- Inherits:
-
Object
- Object
- DYI::Shape::Path::CommandBase
show all
- Defined in:
- lib/dyi/shape/path.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(relative, preceding_command, point) ⇒ CommandBase
Returns a new instance of CommandBase.
608
609
610
611
612
|
# File 'lib/dyi/shape/path.rb', line 608
def initialize(relative, preceding_command, point)
@relative = relative
@preceding_command = preceding_command
@point = Coordinate.new(point)
end
|
Instance Attribute Details
#point ⇒ Object
606
607
608
|
# File 'lib/dyi/shape/path.rb', line 606
def point
@point
end
|
#preceding_command ⇒ Object
606
607
608
|
# File 'lib/dyi/shape/path.rb', line 606
def preceding_command
@preceding_command
end
|
Class Method Details
.absolute_commands(preceding_command, *args) ⇒ Object
655
656
657
|
# File 'lib/dyi/shape/path.rb', line 655
def absolute_commands(preceding_command, *args)
commands(false, preceding_command, *args)
end
|
.relative_commands(preceding_command, *args) ⇒ Object
651
652
653
|
# File 'lib/dyi/shape/path.rb', line 651
def relative_commands(preceding_command, *args)
commands(true, preceding_command, *args)
end
|
Instance Method Details
#absolute? ⇒ Boolean
618
619
620
|
# File 'lib/dyi/shape/path.rb', line 618
def absolute?
!relative?
end
|
#last_point ⇒ Object
626
627
628
|
# File 'lib/dyi/shape/path.rb', line 626
def last_point
relative? ? preceding_point + @point : @point
end
|
#preceding_point ⇒ Object
630
631
632
|
# File 'lib/dyi/shape/path.rb', line 630
def preceding_point
preceding_command && preceding_command.last_point
end
|
#relative? ⇒ Boolean
614
615
616
|
# File 'lib/dyi/shape/path.rb', line 614
def relative?
@relative
end
|
#start_point ⇒ Object
622
623
624
|
# File 'lib/dyi/shape/path.rb', line 622
def start_point
preceding_command.start_point
end
|
#to_compatible_commands(preceding_command) ⇒ Object
634
635
636
637
638
|
# File 'lib/dyi/shape/path.rb', line 634
def to_compatible_commands(preceding_command)
compat_commands = clone
compat_commands.preceding_command = preceding_command
compat_commands
end
|
#used_same_command? ⇒ Boolean
640
641
642
|
# File 'lib/dyi/shape/path.rb', line 640
def used_same_command?
preceding_command.instructions_char == instructions_char
end
|