A
A
arruah2019-02-05 19:01:39
ruby
arruah, 2019-02-05 19:01:39

How to customize gets.chomp input string in ruby?

There is a task on the course on Ruby. When the user enters a line through, show him the symbol ">" at the beginning of the input line. And you need to implement it through the method. Is it possible to make this symbol "blink" or "flicker" I don't know how to put it correctly. :) This is already a gag.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oh_shi, 2019-02-05
@oh_shi

Use print, this as putssoon as without a line break.

puts 'wtf?'
print '>'
gets.chomp

For "beauty" you can try print "\033[33;5m>\033[0m", but it does not work everywhere. Maybe something from https://github.com/fazibear/colorize will do, although it's not worth dragging an extra library for this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question