In Windows I have to use cls
to clear the Console, in Linux just clear
!
Is there a Function like:
system("cls")
or system("clear")
In Windows I have to use cls
to clear the Console, in Linux just clear
!
Is there a Function like:
system("cls")
or system("clear")
Nope, an already written method for both does not exists in ruby native libs. However, you can do something like that :
module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def OS.unix?
!OS.windows?
end
def OS.linux?
OS.unix? and not OS.mac?
end
end
then :
def clear_console
if OS.windows?
system("cls")
else
system("clear")
end
end
credit goes to Aaron Hinni for the OS
module.