Re: [yast-devel] some ruby/rails code tips

2009-04-27 Thread Duncan Mac-Vicar Prett
Some more ruby tips date parsing: @time_string = @systemtime.currenttime.hour.to_s @time_string << ":" @time_string << @systemtime.currenttime.min.to_s -> @time_string = @systemtime.currenttime.strftime("%H:%M") The other way around is also valid, instead of manually splitting the time, just s

[yast-devel] some ruby/rails code tips

2009-04-26 Thread Duncan Mac-Vicar P.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Some stuff I noticed in the code that I collected as tips :-) - - obj == nil -> obj.nil? - - str.length > 0 -> str.empty? - - if str && str.length > 0 This is tricky, not only because str.length should be tested with empty, but this test is s