Class: DYI::Shape::Path::CommandBase

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

Overview

Since:

  • 0.0.0

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.

Since:

  • 0.0.0



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

#pointObject (readonly)

Since:

  • 0.0.0



606
607
608
# File 'lib/dyi/shape/path.rb', line 606

def point
  @point
end

#preceding_commandObject

Since:

  • 0.0.0



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

Since:

  • 0.0.0



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

Since:

  • 0.0.0



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

Returns:

  • (Boolean)

Since:

  • 0.0.0



618
619
620
# File 'lib/dyi/shape/path.rb', line 618

def absolute?
  !relative?
end

#last_pointObject

Since:

  • 0.0.0



626
627
628
# File 'lib/dyi/shape/path.rb', line 626

def last_point
  relative? ? preceding_point + @point : @point
end

#preceding_pointObject

Since:

  • 0.0.0



630
631
632
# File 'lib/dyi/shape/path.rb', line 630

def preceding_point
  preceding_command && preceding_command.last_point
end

#relative?Boolean

Returns:

  • (Boolean)

Since:

  • 0.0.0



614
615
616
# File 'lib/dyi/shape/path.rb', line 614

def relative?
  @relative
end

#start_pointObject

Since:

  • 0.0.0



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

Since:

  • 0.0.0



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

Returns:

  • (Boolean)

Since:

  • 0.0.0



640
641
642
# File 'lib/dyi/shape/path.rb', line 640

def used_same_command?
  preceding_command.instructions_char == instructions_char
end