Try STDIN.gets.chomp and tell us if the input is the same.

Kernel#gets
Returns (and assigns to $_) the next line from the list of files in
ARGV (or $*), or from standard input if no files are present on the
command line.

Perhaps it's getting its input from a file in ARGV (command line arguments).

Abinoam Jr.

On Wed, Jan 29, 2014 at 11:09 AM, Serguei Cambour <lists / ruby-forum.com> wrote:
> I can't figure out where the input comes from in the following code:
>
> def check_input
>       puts "In which city do you stay?"
>       STDOUT.flush
>       city = gets.chomp
>       puts "The city is " + city
> end
>
> When calling in a separate way:
>
> Laby::Engine.new(nil, nil).check_input
>
> it works as needed.
>
> When I tried to call the same from another place
> [project_root/bin/play.rb]
>
> $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
> require 'laby'
>
> Laby::Engine.new(nil, nil).check_input
>
> I'm getting the below output:
>
> In which city do you stay?
> The city is ################################
>
> and the program exits. Really weird...
> Any idea? Thank you.
>
> --
> Posted via http://www.ruby-forum.com/.