Ruby String Object Empty or Not?

I have a string that is the result of Ruby on Rails render_to_string

When in the Ruby debugger this is what I get

pp string.inspect # ->  blank
pp string         # ->  blank
pp string.Class   # ->  String
pp string.empty?  # ->  false
pp string.nil?    # ->  false
pp string.blank?  # ->  false
pp string.to_s    # ->  blank

I know there is content in the string because it logger.info stringreturns the string as expected, but I don't know how to get to it.

Any ideas? Thank!

EDIT: I realized that this problem is very localized. This only happens when I use ruby-debugger. And this happens with any line that has a percent sign.

For example, if I made a line

string = 'this is a string with a % symbol'

the string can no longer be checked, printed, or even unpacked.

I am on Ruby 1.8 and Rails 2.3.

I think this may just be part of my lack of understanding about something mundane in Ruby.

+5
1

, .

hexdump String :

require 'hexdump'

#... whatever you do in your program

puts string.hexdump

?

, , , .

:

http://www.unixgods.org/~tilo/Ruby/hexdump.html

+2

All Articles