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 "nokogiri"
|
||||||
require "json"
|
require "json"
|
||||||
require "paint"
|
require "paint"
|
||||||
require_relative "../../binlib/line"
|
require_relative "../../binlib/io/line"
|
||||||
|
|
||||||
##
|
##
|
||||||
# Configuration variables.
|
# Configuration variables.
|
||||||
|
@ -24,7 +24,7 @@ delay = 1.5
|
||||||
|
|
||||||
##
|
##
|
||||||
# Utils
|
# Utils
|
||||||
line = Line.new($stdout)
|
line = IO::Line.new($stdout)
|
||||||
find_content = ->(res) do
|
find_content = ->(res) do
|
||||||
html = Nokogiri::HTML(res.body)
|
html = Nokogiri::HTML(res.body)
|
||||||
el = html.css("div[class^='TranslationText']").last
|
el = html.css("div[class^='TranslationText']").last
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Line
|
class IO::Line
|
||||||
def initialize(io)
|
def initialize(io)
|
||||||
@io = io
|
@io = io
|
||||||
@size = 0
|
@size = 0
|
||||||
|
@ -11,19 +11,18 @@ class Line
|
||||||
end
|
end
|
||||||
|
|
||||||
def print(str)
|
def print(str)
|
||||||
str = str.gsub(/\n*/, "")
|
tap do
|
||||||
@size = str.size
|
str = str.gsub(/\n*/, "")
|
||||||
@io.print str
|
@size = str.size
|
||||||
self
|
@io.print(str)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def end
|
def end
|
||||||
@io.print "\n"
|
tap { @io.print "\n" }
|
||||||
self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def rewind
|
def rewind
|
||||||
@io.print "\b \b" * @size
|
tap { @io.print "\b \b" * @size }
|
||||||
self
|
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue