Module: PryCoolline::ParenMatch

Defined in:
lib/pry-coolline/paren_match.rb

Defined Under Namespace

Modules: AST Classes: Pair, Parser, Token

Constant Summary collapse

Pairs =
{
  "(" => ")",
  "[" => "]",
  "{" => "}",
}
AnsiCode =
%r{(\e\[\??\d+(?:[;\d]*)\w)}
OpenToken =
Class.new(Token)
CloseToken =
Class.new(Token)
StrToken =
Class.new(Token)

Class Method Summary collapse

Class Method Details

.pair_at(code, pos, pairs = Pairs) ⇒ Pair

Returns An (open, close) pair. Notice both the opening and closing tokens coud be nil.

Parameters:

  • code (String)
  • pos (Integer)

    Position of the selected character, disregarding ANSI codes.

  • pairs (Hash<String, String>) (defaults to: Pairs)

    A hash mapping each opening character to a closing one.

Returns:

  • (Pair)

    An (open, close) pair. Notice both the opening and closing tokens coud be nil.



255
256
257
# File 'lib/pry-coolline/paren_match.rb', line 255

def pair_at(code, pos, pairs = Pairs)
  Parser.parse(code, pairs).pair_at pos
end