From: Eric Christopherson Date: 2011-07-27T08:13:06+09:00 Subject: Re: How do I pass a variable to the Chroinc library function? On Tue, Jul 26, 2011 at 5:53 PM, Terry Improv_coder wrote: > require 'chronic' > > puts "Enter the day of the week, and the date will be displayed " > > inputday = gets.downcase.chomp! > > # User enters > #    monday > > > nextdate = Chronic.parse('next inputday') This sends it the exact string 'next inputday', when what you want to do is make a string from 'next ' + the contents of inputday. There are several ways to do that: # String interpolation (requires double quotes) nextdate = Chronic.parse("next #{inputday}") # String concatenation (single or double quotes) nextdate = Chronic.parse('next ' + inputday) nextdate = Chronic.parse("next " + inputday) etc. > > > puts "The next", inputday, "is " > > puts nextdate > > exit > > ******************************* > > > I have tried every $, @ , @@ and single quotes and double quote > combinations I can think of. It sounds like you need to review the differences between global ($), instance (@), and class (@@) variables, on the one hand; and local variables. inputday is a local variable, since it doesn't start with a distinguishing symbol; $inputday, @inputday, and @@inputday would all be different. > I can use the Time.now with offsets to get > the result I > need > But I am interested in having the 'next inputday' arguments evaluated > before Chronic uses them.  I tried the eval command, but that did not > work. > > Any ideas, thanks in advance. > > Kindly > > taz-uker