On Tue, Mar 30, 2010 at 2:18 PM, Robert Klemme
<shortcutter / googlemail.com> wrote:
> 2010/3/30 Jesse B. <jessebos / aol.com>:
>> This second post with the "spaces only" fix seems to meet all the needs
>> of what I was looking for.
>>
>> I love that this got 9 replies in the middle of the night.
>> thanks everyone for your help.
>
> What do you mean, middle of the night?   > sun isn't even going to settle soon. ;-)
>
> robert
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/

Well, it's also nowhere near the middle of the night here
(n*100 kilometres west of Robert?, where 0 < n < 13?)
but it's definitely not "quite sunny"! In fact, it's raining!
(To quote from "A Song of the Weather"
  by Flanders and Swann - 1950s/1960s sort of English Tom Lehrer's:
  April brings the sweet spring showers.
  On and on for hours and hours.)

How about this? I think it's different from the other solutions(?),
it seems to work, and it doesn't create a string object(?).
  (str =~ /[^ ]/) || str.length

def q( str )
  ns = str =~ /[^ ]/ || str.length  # actual code
  spaces = str[/\A */].length # Robert's 2nd post
  str.inspect.ljust(10) + "  #=> " + ns.inspect + "  =?=  " + spaces.inspect
end

""          #=> 0  =?=  0
" "         #=> 1  =?=  1
"  "        #=> 2  =?=  2
"c"         #=> 0  =?=  0
" c"        #=> 1  =?=  1
"  c"       #=> 2  =?=  2
" \t cc"    #=> 1  =?=  1