Skip to content

Instantly share code, notes, and snippets.

@swarley
Created November 19, 2012 06:56
Show Gist options
  • Select an option

  • Save swarley/4109319 to your computer and use it in GitHub Desktop.

Select an option

Save swarley/4109319 to your computer and use it in GitHub Desktop.
pry-hack/load
[2] pry(main)> require "pry/hack/load"
=> true
[3] pry(main)> Pry.add_hack(:method, :peek_ivar, Pry::Hackage::Hack.new(/@(.+?)$/) { replace_with "instance_variable_get(:@#{capture 1})" })
=> #<Pry::Hackage::Hack:0x00000002540838
@CODE=#<Proc:0x000000025407e8@(pry):3>,
@PATTERN=/@(.+?)$/>
[4] pry(main)> Pry.config.hack.enabled = true
=> true
[5] pry(main)> class Test; def initialize; @ivar = :defined; end; end
=> nil
[6] pry(main)> load "./t/test.rb"
=> true
[7] pry(main)> $k
=> #<Test:0x0000000281edc0 @ivar=:defined>
[8] pry(main)> cat ./t/test.rb
$k = Test.new
$k.@ivar
[9] pry(main)> $k
=> #<Test:0x0000000281edc0 @ivar=:defined>
@lada1234

Copy link
Copy Markdown

Pasali po?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment