Sha256: faad825c81026196d8019fa227f8f30cf943549949bc9d420acc9269cda1550d

Contents?: true

Size: 548 Bytes

Versions: 2

Compression:

Stored size: 548 Bytes

Contents

module Vedeu
  class Position

    # @param y [Fixnum]
    # @param x [Fixnum]
    # @return [Position]
    def initialize(y = 1, x = 1)
      @y, @x = y, x
    end

    # @param block [Proc]
    # @return [String]
    def to_s(&block)
      if block_given?
        [ sequence, yield, sequence ].join

      else
        sequence

      end
    end

    private

    def sequence
      ["\e[", y, ';', x, 'H'].join
    end

    def y
      (@y == 0 || @y == nil) ? 1 : @y
    end

    def x
      (@x == 0 || @x == nil) ? 1 : @x
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.1.17 lib/vedeu/support/position.rb
vedeu-0.1.16 lib/vedeu/support/position.rb