Interactive ruby is like the really poor cousin to ipython. Commandline completion is not on by default, you want to enable it using:
alias irb='irb -r irb/completion'and apparently the only way to get syntax highlighting is to install the wirble gem.
There are a bunch of ways to run shell commands. The one I used was %x:
cmd = "dscl . -read #{file} #{key} 2> /dev/null" output = %x{#{cmd}}
I was looking for a equivalent of the python string function 'startswith'. The ruby equivalent actually has a ? in the function name (WTF?):
if output.start_with?("#{key}: ")
No comments:
Post a Comment