Sha256: ddf1119b6414d2599851eb909677b33efc1fb04255730b270bb537218635a657

Contents?: true

Size: 568 Bytes

Versions: 4

Compression:

Stored size: 568 Bytes

Contents

module Vedeu

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

    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::PositionIndex]
    def initialize(y, x)
      @y = [(y - 1), 1].max
      @x = [(x - 1), 1].max
    end

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

  end # PositionIndex

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.4.2 lib/vedeu/output/position_index.rb
vedeu-0.4.1 lib/vedeu/output/position_index.rb
vedeu-0.4.0 lib/vedeu/output/position_index.rb
vedeu-0.3.5 lib/vedeu/output/position_index.rb