I there a way to configure IRB so that it always display the result of a
IRB command in YAML or PP format.
Example:
In YAML:
irb(main):011:0> ENV.keys
···
---
- ALLUSERSPROFILE
- APPDATA
- APR_ICONV_PATH
- ATI_PATH
- BERK_PATH
- CLASSPATH
- CLIENTNAME
Pretty print:
irb(main):015:0> ENV.key
["ALLUSERSPROFILE",
"APPDATA",
"APR_ICONV_PATH",
"THG_ICON_PATH",
"WINDOWS_PATH"]
--
Posted via http://www.ruby-forum.com/.
Martin Martinos wrote:
I there a way to configure IRB so that it always display the result of a
IRB command in YAML or PP format.
Put this in your .irbrc and play around a little:
require 'yaml'
class IRB::Irb
def output_value
if @context.inspect?
printf @context.return_format, @context.last_value.to_yaml
else
printf @context.return_format, @context.last_value
end
end
end
···
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Thanks Joel, it works perfectly.
Martinos
···
--
Posted via http://www.ruby-forum.com/.