Simplify `Pry::Code#to_s`

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Ensure `max_width` is always an Integer

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Break up `Pry::Code#between`

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Refactor `Pry::Code#between`

Split some parts of it into small methods.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Add comments to protected methods of `Pry::Code`

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Revert "Simplify method chain (use 'map.with_index')"

This reverts commit a1f0a00b65ca9394e7a2071c6a2d6384cbe43e44.

It doesn't compatible with 1.8.7, ree, rbx-18mode, jruby-18mode.
Slightly refactor help command
find-method command: break up large/complicated methods
minor refactor to wtf command
find-method refactor: 'pattern' becomes a method
Assign default value to `:listing` option

When you create a class command, there is a problem with `:listing`
option, which doesn't carry the correct default value. Consider the
example:

  class MakeMeHappy < Pry::ClassCommand
    match 'woot'
  end

`MakeMeHappy` command matches against 'woot' String, but its `:listing`
option is set to the "nil" String, which is incorrect. We can fix it by
setting `:listing` explicitly:

  command_options :listing => 'woot'

It's a repetitive task, so we can automate it. Holy smoke, this why we
all use computers, after all!

With help of this commit there is no need to set `:listing` manually.
Pry will handle it for you.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Rename "Fixnum" to "Integer" in YARD docs

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Extract out some code from Code class

Create a new class called `LOC`, which represents a tuple of a line and
a line number (lineno). `LOC` contains methods that operate on a line.
For example, you can colorize it, or add a line number. The idea is to
make the code of `Pry::Code` more readable. It is clear to me that the
current code allows us to single out a new unit: a line of code.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Add some comments for `Pry::Code::LOC`

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Rename `add_line_numbers` to `add_line_number`

Rename the instance method of `Pry::Code::LOC`.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Document `Pry::Code::LOC#add_marker`

I thought about some changes that I could make with this method, but
then I realised that it's already quite good.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Change @yield YARD tag for `Pry::Code#select`

It yields `LOC` now. Oh, and also prettify some default method
arguments.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Implement `Pry::Code::CodeRange`

Extract some protected methods from `Pry::Code` and add them into its
own class. Name it `CodeRange`, because it operates on numbers and
represents a range of lines of code.

This commit simplifies `Pry::Code`.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Move `LOC` and `CodeRange` to their own files

`Pry::Code` is not cluttered anymore.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
renamed reload-method to reload-code and extended functionality

Should now be able to reload any valid code object, including: methods, modules, commands, procs, etc