class_docstr: For `Ruby <http://www.ruby-lang.org>`_ source code.
class_docstr_tok: ["For","`","Ruby","<","http",":","\/\/www.ruby-lang.org",">","`","_","source","code","."]
code: def heredoc_callback(self, match, ctx):
      # okay, this is the hardest part of parsing Ruby...
      # match: 1 = <<[-~]?, 2 = quote? 3 = name 4 = quote? 5 = rest of line
  
      start = match.start(1)
      yield start, Operator, match.group(1)  # <<[-~]?
      yield match.start(2), String.Heredoc, match.group(
          2
      )  # quote ", ', `
      yield match.start(3), String.Delimiter, match.group(
          3
      )  # heredoc name
      yield match.start(4), String.Heredoc, match.group(
          4
      )  # quote again
  
      heredocstack = ctx.__dict__.setdefault("heredocstack", [])
      outermost = not bool(heredocstack)
      heredocstack.append(
          (match.group(1) in ("<<-", "<<~"), match.group(3))
      )
  
      ctx.pos = match.start(5)
      ctx.end = match.end(5)
      # this may find other heredocs
      for i, t, v in self.get_tokens_unprocessed(context=ctx):
          yield i, t, v
      ctx.pos = match.end()
  
      if outermost:
          # this is the outer heredoc again, now we can process them all
          for tolerant, hdname in heredocstack:
              lines = []
              for match in line_re.finditer(ctx.text, ctx.pos):
                  if tolerant:
                      check = match.group().strip()
                  else:
                      check = match.group().rstrip()
                  if check == hdname:
                      for amatch in lines:
                          yield amatch.start(), String.Heredoc, amatch.group()
                      yield match.start(), String.Delimiter, match.group()
                      ctx.pos = match.end()
                      break
                  else:
                      lines.append(match)
              else:
                  # end of heredoc not found -- error!
                  for amatch in lines:
                      yield amatch.start(), Error, amatch.group()
          ctx.end = len(ctx.text)
          del heredocstack[:]
  
file_path: catboost/contrib/python/Pygments/py2/pygments/lexers/ruby.py
imports: import re
  from pygments.lexer import Lexer, RegexLexer, ExtendedRegexLexer, include, bygroups, default, LexerContext, do_insertions, words
  from pygments.token import Text, Comment, Operator, Keyword, Name, String, Number, Punctuation, Error, Generic
  from pygments.util import shebang_matches
label_desc: Use image node_id 1 for calling the RubyLexer obj's underlying member method code with example usage: obj.heredoc_callback(match, ctx) without return types