Class: DYI::Shape::Path::MoveCommand

Inherits:
CommandBase show all
Defined in:
lib/dyi/shape/path.rb

Overview

Since:

  • 0.0.0

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?

Constructor Details

This class inherits a constructor from DYI::Shape::Path::CommandBase

Class Method Details

.commands(relative, preceding_command, *points) ⇒ Object

Raises:

  • (ArgumentError)

Since:

  • 0.0.0



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_charObject

Since:

  • 0.0.0



679
680
681
# File 'lib/dyi/shape/path.rb', line 679

def instructions_char
  relative? ? 'm' : 'M'
end

#last_pointObject

Since:

  • 0.0.0



667
668
669
# File 'lib/dyi/shape/path.rb', line 667

def last_point
  (relative? && preceding_command.nil?) ? point : super
end

#relative?Boolean

Returns:

  • (Boolean)

Since:

  • 0.0.0



671
672
673
# File 'lib/dyi/shape/path.rb', line 671

def relative?
  preceding_command.nil? ? false : super
end

#start_pointObject

Since:

  • 0.0.0



663
664
665
# File 'lib/dyi/shape/path.rb', line 663

def start_point
  last_point
end

#to_concise_syntax_fragmentsObject

Since:

  • 0.0.0



675
676
677
# File 'lib/dyi/shape/path.rb', line 675

def to_concise_syntax_fragments
  instructions_char + @point.to_s
end