Class: DYI::Shape::Path::MoveCommand
Overview
Instance Attribute Summary
Attributes inherited from CommandBase
#point, #preceding_command
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from CommandBase
#absolute?, absolute_commands, #initialize, #preceding_point, relative_commands, #to_compatible_commands, #used_same_command?
Class Method Details
.commands(relative, preceding_command, *points) ⇒ Object
684
685
686
687
688
689
690
|
# File 'lib/dyi/shape/path.rb', line 684
def commands(relative, preceding_command, *points)
raise ArgumentError, 'wrong number of arguments (2 for 3)' if points.empty?
commands = [new(relative, preceding_command, points.first)]
points[1..-1].inject(commands) do |cmds, pt|
cmds << LineCommand.new(relative, cmds.last, pt)
end
end
|
Instance Method Details
#instructions_char ⇒ Object
679
680
681
|
# File 'lib/dyi/shape/path.rb', line 679
def instructions_char
relative? ? 'm' : 'M'
end
|
#last_point ⇒ Object
667
668
669
|
# File 'lib/dyi/shape/path.rb', line 667
def last_point
(relative? && preceding_command.nil?) ? point : super
end
|
#relative? ⇒ Boolean
671
672
673
|
# File 'lib/dyi/shape/path.rb', line 671
def relative?
preceding_command.nil? ? false : super
end
|
#start_point ⇒ Object
663
664
665
|
# File 'lib/dyi/shape/path.rb', line 663
def start_point
last_point
end
|
#to_concise_syntax_fragments ⇒ Object
675
676
677
|
# File 'lib/dyi/shape/path.rb', line 675
def to_concise_syntax_fragments
instructions_char + @point.to_s
end
|