How to get the Ruby documentation from the command line [duplicate]
With pry, it's better to install the pry-doc
gem, and then use the show-doc
command:
[17] pry(main)> show-doc String#inspectFrom: string.c (C Method):Owner: StringVisibility: publicSignature: inspect()Number of lines: 6Returns a printable version of _str_, surrounded by quote marks,with special characters escaped. str = "hello" str[3] = "\b" str.inspect #=> "\"hel\\bo\""[18] pry(main)> show-doc Array#popFrom: array.c (C Method):Owner: ArrayVisibility: publicSignature: pop(*arg1)Number of lines: 11Removes the last element from self and returns it, ornil if the array is empty.If a number n is given, returns an array of the last n elements(or less) just like array.slice!(-n, n) does. See alsoArray#push for the opposite effect. a = [ "a", "b", "c", "d" ] a.pop #=> "d" a.pop(2) #=> ["b", "c"] a #=> ["a"][19] pry(main)>
Note: you can also use the ?
alias for show-doc
if you prefer.