Line -> IO::Line

This commit is contained in:
0x1eef 2022-07-14 22:15:38 -03:00
parent 43939c669b
commit 962c15f706
2 changed files with 10 additions and 11 deletions

View file

@ -14,7 +14,7 @@ require "net/http"
require "nokogiri"
require "json"
require "paint"
require_relative "../../binlib/line"
require_relative "../../binlib/io/line"
##
# Configuration variables.
@ -24,7 +24,7 @@ delay = 1.5
##
# Utils
line = Line.new($stdout)
line = IO::Line.new($stdout)
find_content = ->(res) do
html = Nokogiri::HTML(res.body)
el = html.css("div[class^='TranslationText']").last

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class Line
class IO::Line
def initialize(io)
@io = io
@size = 0
@ -11,19 +11,18 @@ class Line
end
def print(str)
str = str.gsub(/\n*/, "")
@size = str.size
@io.print str
self
tap do
str = str.gsub(/\n*/, "")
@size = str.size
@io.print(str)
end
end
def end
@io.print "\n"
self
tap { @io.print "\n" }
end
def rewind
@io.print "\b \b" * @size
self
tap { @io.print "\b \b" * @size }
end
end