Class: MatchData

Inherits:
Object show all
Defined in:
lib/pp.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#pretty_print(q) ⇒ Object

:nodoc:



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# File 'lib/pp.rb', line 597

def pretty_print(q) # :nodoc:
  nc = []
  self.regexp.named_captures.each {|name, indexes|
    indexes.each {|i| nc[i] = name }
  }
  q.object_group(self) {
    q.breakable
    q.seplist(0...self.size, lambda { q.breakable }) {|i|
      if i == 0
        q.pp self[i]
      else
        if nc[i]
          q.text nc[i]
        else
          q.pp i
        end
        q.text ':'
        q.pp self[i]
      end
    }
  }
end