Sha256: 26fe5bf3c20308870975c4909b35c57dd5dbd667211f724b4ca1e4608adabb66

Contents?: true

Size: 580 Bytes

Versions: 3

Compression:

Stored size: 580 Bytes

Contents

module Vedeu

  # Converts an index into a position for the terminal.
  #
  class IndexPosition

    attr_reader :y,
      :x

    alias_method :first, :y
    alias_method :last, :x

    # @param y [Fixnum]
    # @param x [Fixnum]
    # @return [Array]
    def self.[](y, x)
      new(y, x).[]
    end

    # @param y [Fixnum]
    # @param x [Fixnum]
    # @return [Vedeu::IndexPosition]
    def initialize(y, x)
      @y = (y <= 0) ? 1 : (y + 1)
      @x = (x <= 0) ? 1 : (x + 1)
    end

    # @return [Array]
    def []
      [y, x]
    end

  end # IndexPosition

end # Vedeu

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.4.5 lib/vedeu/output/index_position.rb
vedeu-0.4.4 lib/vedeu/output/index_position.rb
vedeu-0.4.3 lib/vedeu/output/index_position.rb