# still trying to coerce numbers and strings for date math

and still going crazy...

I have tried everything I can think of...

interval

=> 1

dinc

=> "year"

interval.to_s + "." + dinc

=> "1.year"

test = Time.now + (interval.to_s + "." + dinc)

TypeError: no implicit conversion to float from string
from (irb):263:in `+'
from (irb):263

crap...that doesn't work, nor does this...

(interv.to_s + "." + dinc).to_f

=> 1.0

I have to have 'interval' be a number that I can increment while I test
it and 'dinc' to be the value (i.e., month, year) and reconstitute them.

How does one do this?

Craig

and still going crazy...

I have tried everything I can think of...

interval

=> 1

dinc

=> "year"

interval.to_s + "." + dinc

=> "1.year"

test = Time.now + (interval.to_s + "." + dinc)

TypeError: no implicit conversion to float from string
from (irb):263:in `+'
from (irb):263
from :0

crap...that doesn't work, nor does this...

(interv.to_s + "." + dinc).to_f

=> 1.0

I have to have 'interval' be a number that I can increment while I
test
it and 'dinc' to be the value (i.e., month, year) and reconstitute
them.

I suppose the key here is understanding that year/month etc... are
just methods on the integers, so
interval = 1
inc = 'year'
test = Time.now + interval.year
test = Time.now + interval.send(inc)

Fred

>
> and still going crazy...
>
> I have tried everything I can think of...
>
>>> interval
> => 1
>>> dinc
> => "year"
>>> interval.to_s + "." + dinc
> => "1.year"
>>> test = Time.now + (interval.to_s + "." + dinc)
> TypeError: no implicit conversion to float from string
> from (irb):263:in `+'
> from (irb):263
> from :0
>
> crap...that doesn't work, nor does this...
>
>>> (interv.to_s + "." + dinc).to_f
> => 1.0
>
> I have to have 'interval' be a number that I can increment while I
> test
> it and 'dinc' to be the value (i.e., month, year) and reconstitute
> them.

I suppose the key here is understanding that year/month etc... are
just methods on the integers, so
interval = 1
inc = 'year'
test = Time.now + interval.year
test = Time.now + interval.send(inc)