0

I use HighLine gem for UI. I want to clear the screen before output any data. Which method should I use? Patch some Ruby methods like puts? Patch HighLine? Change my app in some way? At the moment it has Dialog class with various methods which call HighLine functions for interacting with user. Or maybe HighLine has a built-in method to do that?

Community
  • 1
  • 1
Michael
  • 135
  • 2
  • 11

1 Answers1

1

Well, the requirements are not clear and I won’t recommend this way, but the stated problem might be solved with:

$stdout.singleton_class.prepend(Module.new do
  def write(string)
    super("\e[2J" << string)
  end
end)

I think, this answer is not suitable for the OP, but it perfectly answers the exact question asked.

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160
  • Yes, you are quite right. It is exactly what I ask for and it is not what I want absolutely. I should manually clear screen in right places of **my app** according to business logic. – Michael Nov 23 '16 at 16:47