class DYI::Shape::Polyline

Public Class Methods

new(start_point, options={}) click to toggle source

@param [Coordinate] start_point a start coordinate of the shape @option options [Painting] :painting painting status of this shape @option options [String] :description the description of this shape @option options [String] :title the title of this shape

# File lib/dyi/shape/base.rb, line 677
def initialize(start_point, options={})
  @points = [Coordinate.new(start_point)]
  @attributes = init_attributes(options)
  @marker = {}
end

Public Instance Methods

bottom() click to toggle source
# File lib/dyi/shape/base.rb, line 721
def bottom
  @points.max {|a, b| a.y <=> b.y}.y
end
current_point() click to toggle source
# File lib/dyi/shape/base.rb, line 693
def current_point
  @points.last
end
left() click to toggle source
# File lib/dyi/shape/base.rb, line 709
def left
  @points.min {|a, b| a.x <=> b.x}.x
end
line_to(*points) click to toggle source
# File lib/dyi/shape/base.rb, line 683
def line_to(*points)
  @points.push(*points.map{|pt| Coordinate.new(pt)})
end
points() click to toggle source
# File lib/dyi/shape/base.rb, line 701
def points
  @points.clone
end
right() click to toggle source
# File lib/dyi/shape/base.rb, line 713
def right
  @points.max {|a, b| a.x <=> b.x}.x
end
rline_to(*points) click to toggle source

@since 1.1.0

# File lib/dyi/shape/base.rb, line 688
def rline_to(*points)
  current = current_point
  @points.push(*points.inject([]){|result, pt| result << (current += pt)})
end
start_point() click to toggle source
# File lib/dyi/shape/base.rb, line 697
def start_point
  @points.first
end
top() click to toggle source
# File lib/dyi/shape/base.rb, line 717
def top
  @points.min {|a, b| a.y <=> b.y}.y
end
undo() click to toggle source
# File lib/dyi/shape/base.rb, line 705
def undo
  @points.pop if @points.size > 1
end
write_as(formatter, io=$>) click to toggle source
# File lib/dyi/shape/base.rb, line 725
def write_as(formatter, io=$>)
  formatter.write_polyline(self, io, &(block_given? ? Proc.new : nil))
end