Class: MatchData

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

Instance Method Summary collapse

Instance Method Details

#pretty_print(q) ⇒ Object



851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
# File 'lib/extensions/mspec/mspec/pp.rb', line 851

def pretty_print(q)
  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