0

I really need to know how to clear the screen in Ruby. I've already looked all over and haven't found anything that can help.

I've already tried using cls in several formats and it NEVER worked (I am on Windows, btw).

All that happens is an arrow keeps showing up in the IRB console.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    which os are you using, `cls` is for windows, for linux or osx it should be `system('clear')` – Subash Mar 18 '18 at 22:46
  • I'm using Windows and like I said, cls didn't work. – Dollarluigi Mar 18 '18 at 22:59
  • What is "the screen"? The console of rubymine? Or in the shell (command.com, powershell...)? If it is in the shell, then `cls`should work. See https://stackoverflow.com/questions/3170553/how-can-i-clear-the-terminal-in-ruby – knut Mar 18 '18 at 23:59
  • Where the program runs when you test it is what I mean. – Dollarluigi Mar 19 '18 at 00:16

3 Answers3

2

To clear the terminal window on multiple operational systems, you could use:

def clear
  if Gem.win_platform?
    system 'cls'
  else
    system 'clear'
  end
end

Documentation for Gem#win_platform?
Is this a windows platform?

vinibrsl
  • 6,563
  • 4
  • 31
  • 44
  • I already said that 'cls' doesn't work and I AM on Windows. All it's doing is having some arrow shape show up in the IRB console. It's not clearintg anything. – Dollarluigi Mar 19 '18 at 16:55
0

I found out earlier today that 'cls' doesn't work in RubyMine but it will work if I run the app in command prompt. It would've been nice if I had been told about that earlier.

-1

on terminal type 'clear' and hit enter button it will clear your screen .

Bodh1004
  • 309
  • 3
  • 9