Sha256: c8e2b603699b3a142aff04402c0e0f1ba721946989c9504a9a68bdf212368174

Contents?: true

Size: 805 Bytes

Versions: 31

Compression:

Stored size: 805 Bytes

Contents

# frozen_string_literal: true

module Torque
  module PostgreSQL
    class Circle < Struct.new(:x, :y, :r)
      alias radius r
      alias radius= r=

      def center
        point_class.new(x, y)
      end

      def center=(value)
        parts = value.is_a?(point_class) ? [value.x, value.y] : value[0..1]
        self.x = parts.first
        self.y = parts.last
      end

      private

        def point_class
          Torque::PostgreSQL.config.geometry.point_class
        end
    end

    config.geometry.circle_class ||= ::ActiveRecord.const_set('Circle', Class.new(Circle))

    module Adapter
      module OID
        class Circle < Torque::PostgreSQL::GeometryBuilder

          PIECES = %i[x y r].freeze
          FORMATION = '<(%s,%s),%s>'.freeze

        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
torque-postgresql-3.4.1 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-2.4.5 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.4.0 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.3.3 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-2.4.4 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.3.2 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-2.4.3 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.3.1 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.3.0 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.2.2 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-2.4.2 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-2.4.1 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.2.1 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-2.4.0 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.2.0 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.1.0 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-2.3.0 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.0.1 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-2.2.4 lib/torque/postgresql/adapter/oid/circle.rb
torque-postgresql-3.0.0 lib/torque/postgresql/adapter/oid/circle.rb