Sha256: e8291bd8ef029c51a67def3527b4b385e143b3802ba5de51a7a269961bb0476a

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

require_relative './common'
require_relative '../point'

module Draught
  module Transformations
    class Proclike
      include Common

      attr_reader :proclike

      def initialize(proclike)
        @proclike = proclike
      end

      def call(point)
        point_from_tuple_or_point(proclike.call(point))
      end

      def affine?
        false
      end

      def ==(other)
        other.respond_to?(:proclike) && proclike == other.proclike
      end

      def flattened_transforms
        [self]
      end

      def coalesce(_)
        raise TypeError, "non-Affine transforms cannot be coalesced"
      end

      private

      def point_from_tuple_or_point(tuple_or_point)
        return Point.new(*tuple_or_point) if tuple_or_point.respond_to?(:each)
        tuple_or_point
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
draught-0.1.0 lib/draught/transformations/proclike.rb