Sha256: 276e5ff053bbaf4fad41862707565ebce1373b40dd6f9cc112c395e0cb037a7b

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Geometries

    # Provide position functionality to the including model.
    #
    # @api private
    #
    module Positionable

      # Gets the position.
      #
      # @return [Vedeu::Geometries::Position]
      def position
        Vedeu::Geometries::Position.coerce(@position)
      end

      # Sets the position.
      #
      # @param value [Array<void>|Hash<void>|
      #   Vedeu::Geometries::Position]
      # @return [Vedeu::Geometries::Position]
      def position=(value)
        @position = Vedeu::Geometries::Position.coerce(value)
      end

      # Returns a boolean indicating the position attribute of the
      # including model is set.
      #
      # @return [Boolean]
      def position?
        position.is_a?(Vedeu::Geometries::Position)
      end

      # Returns the x coordinate for the model when the position
      # attribute of the including model is set.
      #
      # @return [Fixnum|NilClass]
      def x
        position.x if position?
      end

      # Returns the y coordinate for the model when the position
      # attribute of the including model is set.
      #
      # @return [Fixnum|NilClass]
      def y
        position.y if position?
      end

    end # Positionable

  end # Geometries

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.8.4 lib/vedeu/geometries/positionable.rb