Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby: Error: Cannot locate this method: String.

Tags:

ruby

pry

Any idea why certain documentation does not work when using show-doc in pry? E.g. see show-doc with String and Array compared to Set here:

show-doc Set

From: /Users/snowcrash/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/set.rb @ line 3:
Class name: Set
Number of lines: 57

--
set.rb - defines the Set class
++
Copyright (c) 2002-2008 Akinori MUSHA <[email protected]>

Documentation by Akinori MUSHA and Gavin Sinclair.

All rights reserved.  You can redistribute and/or modify it under the same
terms as Ruby.

  $Id: set.rb 37839 2012-11-24 18:51:45Z knu $

== Overview

This library provides the Set class, which deals with a collection

show-doc String
Error: Cannot locate this method: String.
[7] pry(main)> show-doc Array
Error: Cannot locate this method: Array.
like image 847
Snowcrash Avatar asked Feb 19 '26 15:02

Snowcrash


2 Answers

try installing pry-doc gem:

gem install pry-doc

OR

as per @JayKilleen

if you are using pry in your rails environment you can also try installing jazz_hands instead github.com/nixme/jazz_hands which brings pry and other gem functionality into rails console.

like image 90
Sachin Singh Avatar answered Feb 23 '26 10:02

Sachin Singh


String and Array aren't methods, they're classes. That's probably why it's giving you that error there.

like image 37
benbot Avatar answered Feb 23 '26 09:02

benbot