Skip to content

Instantly share code, notes, and snippets.

@banister
Created April 20, 2011 10:22
Show Gist options
  • Save banister/c0fc686ef923c8b87715 to your computer and use it in GitHub Desktop.
Save banister/c0fc686ef923c8b87715 to your computer and use it in GitHub Desktop.

Revisions

  1. banister revised this gist Mar 1, 2012. 1 changed file with 24 additions and 22 deletions.
    46 changes: 24 additions & 22 deletions Pry ls command
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,24 @@
    pry(main)> ls --help
    Usage: ls [OPTIONS] [VAR]
    List information about VAR (the current context by default).
    Shows local and instance variables by default.
    --
    -g, --globals Display global variables.
    -c, --constants Display constants.
    -l, --locals Display locals.
    -i, --ivars Display instance variables.
    -k, --class-vars Display class variables.
    -m, --methods Display methods (public methods by default).
    -M, --instance-methods Display instance methods (only relevant to classes and modules).
    -P, --public Display public methods (with -m).
    -r, --protected Display protected methods (with -m).
    -p, --private Display private methods (with -m).
    -j, --just-singletons Display just the singleton methods (with -m).
    -s, --super Include superclass entries (relevant to constant and methods options).
    -a, --all Display all types of entries.
    -v, --verbose Verbose ouput.
    -f, --flood Do not use a pager to view text longer than one screen.
    --grep REG Regular expression to be used.
    -h, --help Show this message.
    [14] (pry) main: 0> ls -h
    Usage: ls [-m|-M|-p|-pM] [-q|-v] [-c|-i] [Object]
    ls [-g] [-l]

    ls shows you which methods, constants and variables are accessible to Pry. By default it shows you the local variables defined in the current shell, and any public methods or instance variables defined on the current object.

    The colours used are configurable using Pry.config.ls.*_color, and the separator is Pry.config.ls.separator.

    Pry.config.ls.ceiling is used to hide methods defined higher up in the inheritance chain, this is by default set to [Object, Module, Class] so that methods defined on all Objects are omitted. The -v flag can be used to ignore this setting and show all methods, while the -q can be used to set the ceiling much lower and show only methods defined on the object or its direct class.


    options:

    -m, --methods Show public methods defined on the Object (default)
    -M, --instance-methods Show methods defined in a Module or Class
    -p, --ppp Show public, protected (in yellow) and private (in green) methods
    -q, --quiet Show only methods defined on object.singleton_class and object.class
    -v, --verbose Show methods and constants on all super-classes (ignores Pry.config.ls.ceiling)
    -g, --globals Show global variables, including those builtin to Ruby (in cyan)
    -l, --locals Show locals, including those provided by Pry (in red)
    -c, --constants Show constants, highlighting classes (in blue), and exceptions (in purple)
    -i, --ivars Show instance variables (in blue) and class variables (in bright blue)
    -G, --grep Filter output by regular expression
    -h, --help Show this message.
  2. banister created this gist Apr 20, 2011.
    22 changes: 22 additions & 0 deletions Pry ls command
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    pry(main)> ls --help
    Usage: ls [OPTIONS] [VAR]
    List information about VAR (the current context by default).
    Shows local and instance variables by default.
    --
    -g, --globals Display global variables.
    -c, --constants Display constants.
    -l, --locals Display locals.
    -i, --ivars Display instance variables.
    -k, --class-vars Display class variables.
    -m, --methods Display methods (public methods by default).
    -M, --instance-methods Display instance methods (only relevant to classes and modules).
    -P, --public Display public methods (with -m).
    -r, --protected Display protected methods (with -m).
    -p, --private Display private methods (with -m).
    -j, --just-singletons Display just the singleton methods (with -m).
    -s, --super Include superclass entries (relevant to constant and methods options).
    -a, --all Display all types of entries.
    -v, --verbose Verbose ouput.
    -f, --flood Do not use a pager to view text longer than one screen.
    --grep REG Regular expression to be used.
    -h, --help Show this message.