Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > String issue

Reply
Thread Tools

String issue

 
 
Prashant Katare
Guest
Posts: n/a
 
      05-07-2009
Hello,

I am trying to display the time spent in performing an activity in HTML
format.

The code below does that. If the time is 0 it shouldn't show anything
else it should show the "time" followed by "hours" word.

"<td>
#{start_time[:hrs] == 0 ? "" : start_time[:hrs] + hours}
</td>"

The way I am trying to do is giving problems.

"TypeError Exception: String can't be coerced into Fixnum"
This is because of the "+ hours" in the code.

Any solution to get this done?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
RĂ¼diger Brahns
Guest
Posts: n/a
 
      05-07-2009
Prashant Katare schrieb:
> Hello,
>
> I am trying to display the time spent in performing an activity in HTML
> format.
>
> The code below does that. If the time is 0 it shouldn't show anything
> else it should show the "time" followed by "hours" word.
>
> "<td>
> #{start_time[:hrs] == 0 ? "" : start_time[:hrs] + hours}
> </td>"
>
> The way I am trying to do is giving problems.
>
> "TypeError Exception: String can't be coerced into Fixnum"
> This is because of the "+ hours" in the code.
>
> Any solution to get this done?


start_time[:hrs].to_s + hours
 
Reply With Quote
 
 
 
 
Prashant Katare
Guest
Posts: n/a
 
      05-07-2009
Thanks for your solution
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'System.String[]' from its string representation 'String[] Array' =?Utf-8?B?UmFqZXNoIHNvbmk=?= ASP .Net 0 05-04-2006 04:29 PM
Is "String s = "abc";" equal to "String s = new String("abc");"? Bruce Sam Java 15 11-19-2004 06:03 PM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 3 12-05-2003 04:20 PM
Re: String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 0 12-04-2003 04:40 PM



Advertisments