Sha256: bb9e69f7fe96820fcb69c89583925f2ce8bdd09c3b055e9c239945cd2ab89863
Contents?: true
Size: 766 Bytes
Versions: 1
Compression:
Stored size: 766 Bytes
Contents
# frozen_string_literal: true require 'tty-prompt' module Vercon class Stdout def initialize @stdout = $stdout @prompt = TTY::Prompt.new @lines = 0 end def write(message) @stdout.puts(message) @lines += 1 end def erase(lines: nil) (lines || @lines).times do @stdout.print("\e[A\e[K") @lines -= 1 end end %i[ask yes? no? say ok warn error mask select].each do |method| define_method(method) do |*args, &block| @lines += 1 @prompt.send(method, *args, &block) end end %i[puts print].each do |method| define_method(method) do |*args, &block| @lines += 1 @stdout.send(method, *args, &block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vercon-0.0.1 | lib/vercon/stdout.rb |