Sha256: a5e622dba68594ebcafdf2b49a024d267725f6f0185c3c3d9aa6e28bf804d001

Contents?: true

Size: 424 Bytes

Versions: 3

Compression:

Stored size: 424 Bytes

Contents

module Vedeu
  class Position
    def initialize(y = 1, x = 1)
      @y, @x = y, x
    end

    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

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.1.15 lib/vedeu/support/position.rb
vedeu-0.1.14 lib/vedeu/support/position.rb
vedeu-0.1.13 lib/vedeu/support/position.rb