[TxMt] Re: Ruby question on TextMate

Dru Kepple dru at summitprojects.com
Tue Nov 9 21:00:19 UTC 2010

On Nov 9, 2010, at 12:01 PM, Marc Chanliau wrote:

I'm a Ruby newbie. I'm using TexMate Version 1.5.9 (1510) on Mac OS X Version 10.6.4. I'm trying to write a small Ruby snippet to get keyboard input as follows:

puts "What is your name? "
name = gets.chomp
puts "Hello #{name}"

I get the following TextMate error:

NoMethodError: private method ‘chomp’ called for nil:NilClass

I'm no Ruby expert myself, but the problem you're seeing is that "gets" is nil, and therefore has no "chomp" to execute.  "gets" is nil because you have no interactive input.  The sad news is thus:


You might try using TextMate's UI library and get a string from the user, if that's crucial to your snippet.  A very simple example:

require ENV['TM_SUPPORT_PATH'] + '/lib/ui'
userInput = TextMate::UI.request_string()
puts userInput

More information about the textmate mailing list