class Draught::Sheet

Attributes

containers[R]
height[R]
lower_left[R]
width[R]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/draught/sheet.rb, line 10
def initialize(opts = {})
  @containers = opts.fetch(:containers)
  @lower_left = opts.fetch(:lower_left, Point::ZERO)
  @width = opts.fetch(:width)
  @height = opts.fetch(:height)
end

Public Instance Methods

==(other) click to toggle source
# File lib/draught/sheet.rb, line 41
def ==(other)
  lower_left == other.lower_left && width == other.width && height == other.height && containers == other.containers
end
box_type() click to toggle source
# File lib/draught/sheet.rb, line 37
def box_type
  [:container]
end
paths() click to toggle source
# File lib/draught/sheet.rb, line 33
def paths
  containers
end
transform(transformer) click to toggle source
# File lib/draught/sheet.rb, line 23
def transform(transformer)
  tr_lower_left = lower_left.transform(transformer)
  tr_containers = containers.map { |container| container.transform(transformer) }
  extent = Point.new(width, height).transform(transformer)
  tr_width, tr_height = extent.x, extent.y
  self.class.new({
    containers: tr_containers, lower_left: tr_lower_left, width: tr_width, height: tr_height
  })
end
translate(point) click to toggle source
# File lib/draught/sheet.rb, line 17
def translate(point)
  tr_lower_left = lower_left.translate(point)
  tr_containers = containers.map { |container| container.translate(point) }
  self.class.new(containers: tr_containers, lower_left: tr_lower_left, width: width, height: height)
end