Sha256: 3b0ee039a7d0f2922806d45d84ecb1c2cf39d5682837ab916d9fd5a3e509e609

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Presentation

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

      # 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 # Position

  end # Presentation

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.8.13 lib/vedeu/presentation/position.rb
vedeu-0.8.12 lib/vedeu/presentation/position.rb
vedeu-0.8.10 lib/vedeu/presentation/position.rb
vedeu-0.8.9 lib/vedeu/presentation/position.rb
vedeu-0.8.8 lib/vedeu/presentation/position.rb
vedeu-0.8.7 lib/vedeu/presentation/position.rb
vedeu-0.8.6 lib/vedeu/presentation/position.rb
vedeu-0.8.5 lib/vedeu/presentation/position.rb