class DYI::Shape::Line

Public Class Methods

create_on_direction(start_point, direction_x, direction_y, options={}) click to toggle source
# File lib/dyi/shape/base.rb, line 662
def create_on_direction(start_point, direction_x, direction_y, options={})
  start_point = Coordinate.new(start_point)
  end_point = start_point + Coordinate.new(direction_x, direction_y)
  new(start_point, end_point, options)
end
create_on_start_end(start_point, end_point, options={}) click to toggle source
# File lib/dyi/shape/base.rb, line 658
def create_on_start_end(start_point, end_point, options={})
  new(start_point, end_point, options)
end
new(start_point, end_point, options={}) click to toggle source

@param [Coordinate] start_point a start coordinate of the line @param [Coordinate] end_point an end coordinate of the line @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 627
def initialize(start_point, end_point, options={})
  @start_point = Coordinate.new(start_point)
  @end_point = Coordinate.new(end_point)
  @attributes = init_attributes(options)
  @marker = {}
end

Public Instance Methods

bottom() click to toggle source
# File lib/dyi/shape/base.rb, line 646
def bottom
  [@start_point.y, @end_point.y].max
end
left() click to toggle source
# File lib/dyi/shape/base.rb, line 634
def left
  [@start_point.x, @end_point.x].min
end
right() click to toggle source
# File lib/dyi/shape/base.rb, line 638
def right
  [@start_point.x, @end_point.x].max
end
top() click to toggle source
# File lib/dyi/shape/base.rb, line 642
def top
  [@start_point.y, @end_point.y].min
end
write_as(formatter, io=$>) click to toggle source
# File lib/dyi/shape/base.rb, line 650
def write_as(formatter, io=$>)
  formatter.write_line(self, io, &(block_given? ? Proc.new : nil))
end