+1 for noodlejar. I always liked thoughtbot. Just keep the graphic,
uh, not too graphic.
At 06:57 AM 1/22/2010, you wrote:
You should take this puzzle down to Jelly today and harass the
creative types at The Hive.
On Jan 21, 2010, at 11:24 PM, Peter Gumeson wrote:
Hi gang,
I've been
Thanks Nic. Would love to, but I'm on-site now a days. If you Jelly folk
have any thoughts then please do chime in.
Peter
On Fri, Jan 22, 2010 at 6:57 AM, Nic Benders nic.bend...@gmail.com wrote:
You should take this puzzle down to Jelly today and harass the creative
types at The Hive.
On
I'm looking for a simple way to check if a string really represents
a number in ruby/rails. I figured there would be a String.is_numeric?
but haven't found anything.
I've seen suggestions for roll-your-own functions the best of which
appears to be something like (verbosely):
def
/\d+(\.\d+)?/ =~ some_number
Doesn't do what you need? Is there an obvious edge case I'm missing? A
number is one or more digits, optionally followed by a . and one or
more digits.
=~ will give you nil if it doesn't match, or the index of the match if
it does (which you can just use as non
On Jan 21, 2010, at 11:24 PM, Peter Gumeson wrote:
I've been doing consulting under my own name for quite some time,
which I know is quite boring and uncool.
IMO if you work primarily solo, and you expect to stay that way, then
your name is the best brand you could have. *You* are who you
As an obscure case, Ruby supports the '_' as a thousands separator. There
might be others.
10_000.to_i
= 1
On Jan 22, 2010, at 11:43 AM, Kevin Clark wrote:
/\d+(\.\d+)?/ =~ some_number
Doesn't do what you need? Is there an obvious edge case I'm missing? A
number is one or more
I would rescue only the TypeError. Rescueing all exceptions is asking for a
hard to track down bug down the road.
-Brad
On Fri, Jan 22, 2010 at 11:35 AM, Glenn Little lit...@cs.ucsd.edu wrote:
I'm looking for a simple way to check if a string really represents
a number in ruby/rails. I
On Jan 22, 2010, at 11:35 AM, Glenn Little wrote:
I'm looking for a simple way to check if a string really represents
a number in ruby/rails. I figured there would be a String.is_numeric?
but haven't found anything.
I have independent interpretations of is_numeric and represents_number.
Actually, negatives and scientific both currently return true with
Kevin's example. Unfortunately, so do a lot of others :)
some_number = 'any string with a number like 4 in it will be true but
not a number'
And yes, as you fix those false positives, you begin introducing the
false
well... you can just do:
class String
def is_numeric?
!self.to_f.nil?
end
end
- Matt
On Fri, Jan 22, 2010 at 12:18 PM, Greg Willits g...@railsdev.ws wrote:
On Jan 22, 2010, at 11:35 AM, Glenn Little wrote:
I'm looking for a simple way to check if a string really represents
a
nevermind, I should have tested my code
class String
def is_numeric?
!self.to_f.zero? || self == '0' || self == '0.0'
end
end
'test'.is_numeric?
= false
'123cm'.is_numeric?
= true
'10_000'.is_numeric?
= true
Of course that's not a perfect solution
- Matt
On Fri, Jan 22, 2010 at
to_f is too smart:
5.not_a_number.to_f
= 5.0
-glenn
Matt Aimonetti wrote:
well... you can just do:
class String
def is_numeric?
!self.to_f.nil?
end
end
- Matt
On Fri, Jan 22, 2010 at 12:18 PM, Greg Willits g...@railsdev.ws
mailto:g...@railsdev.ws wrote:
On Jan
Yup, thanks... just noticed that about ArgumentError. I'm actually
catching both now, that way nils work gracefully. Although
one could have an argument about whether nil represents
a number or not. :)
-glenn
Jason King wrote:
Actually, negatives and scientific both currently return
On Fri, Jan 22, 2010 at 12:22, Jason King smathy.w...@gmail.com wrote:
Only comment I have for you *Glenn* is that I can't see any reason for the
conditional, and it's an ArgumentError not a TypeError that's thrown. I
think your method becomes simply:
def represents_number?(s)
Float(s)
Good advice Greg. When I said it's uncool and boring, I really meant more
in the context of my own boring and uncool name :) It's great for those of
you naturally born with great software names (yes, we're talking about you
Jordan Fowler).
Also should have mentioned that I want the flexibility
On Fri, Jan 22, 2010 at 12:55, Peter Gumeson gume...@gmail.com wrote:
Good advice Greg. When I said it's uncool and boring, I really meant more
in the context of my own boring and uncool name :)
As someone with an intimidatingly-spelled last name (it's phonetic!
really!), I feel you on that
On Jan 22, 2010, at 12:55 PM, Peter Gumeson wrote:
Good advice Greg. When I said it's uncool and boring, I really
meant more in the context of my own boring and uncool name :) It's
great for those of you naturally born with great software names
(yes, we're talking about you Jordan
nevermind
- Roseanne Roseannadanna
oops, - Emily Litella (the little old lady), not RR
--
SD Ruby mailing list
sdruby@googlegroups.com
http://groups.google.com/group/sdruby
18 matches
Mail list logo