Skip to content

Instantly share code, notes, and snippets.

@swarley
Created November 19, 2012 00:55
Show Gist options
  • Save swarley/4108401 to your computer and use it in GitHub Desktop.
Save swarley/4108401 to your computer and use it in GitHub Desktop.
pry/pry-hack
[1] pry(main)> load "./hack.rb"; Pry.config.hack.enabled = true
=> true
[2] pry(main)> Pry.add_hack(:%, :symbol_array, Pry::Hackage::ModOpHack.new('S') { replace_with "%w#{capture 1}#{capture 2}#{capture 3}.map(&:to_sym)" })
=> #<Pry::Hackage::ModOpHack:0x00000001081140
@CHAR="S",
@CODE=#<Proc:0x00000001088f80@(pry):2>>
[3] pry(main)> %S{hello symbol world! i bet everyone is jealous of pry now}
=> [:hello, :symbol, :world!, :i, :bet, :everyone, :is, :jealous, :of, :p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment