Line -> IO::Line
This commit is contained in:
parent
43939c669b
commit
962c15f706
2 changed files with 10 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
tap do
|
||||
str = str.gsub(/\n*/, "")
|
||||
@size = str.size
|
||||
@io.print str
|
||||
self
|
||||
@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
|
Loading…
Reference in a new issue