Sha256: b126e5f211f51ee655d355aa4cf371626e9ab52b9b4be0fd3089a73e5ee76e00

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

require_relative 'boxlike'
require 'forwardable'

module Draught
  class Container
    extend Forwardable
    include Boxlike

    attr_reader :box, :min_gap

    def_delegators :box, :lower_left, :width, :height, :containers

    def initialize(box, opts = {})
      @box = box
      @min_gap = opts.fetch(:min_gap, 0)
    end

    def translate(point)
      self.class.new(box.translate(point), {min_gap: min_gap})
    end

    def transform(transformer)
      transformed_min_gap = Point.new(min_gap,0).transform(transformer).x
      self.class.new(box.transform(transformer), {min_gap: transformed_min_gap})
    end

    def ==(other)
      min_gap == other.min_gap && box == other.box
    end

    def box_type
      [:container]
    end

    def paths
      [box]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
draught-0.1.0 lib/draught/container.rb