Class: Data

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

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#pretty_print(q) ⇒ Object

:nodoc:



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/pp.rb', line 456

def pretty_print(q) # :nodoc:
  class_name = PP.mcall(self, Kernel, :class).name
  class_name = " #{class_name}" if class_name
  q.group(1, "#<data#{class_name}", '>') {

    members = PP.mcall(self, Kernel, :class).members
    values = []
    members.select! do |member|
      begin
        values << __send__(member)
        true
      rescue NoMethodError
        false
      end
    end

    q.seplist(members.zip(values), lambda { q.text "," }) {|(member, value)|
      q.breakable
      q.text member.to_s
      q.text '='
      q.group(1) {
        q.breakable ''
        q.pp value
      }
    }
  }
end

#pretty_print_cycle(q) ⇒ Object

:nodoc:



484
485
486
# File 'lib/pp.rb', line 484

def pretty_print_cycle(q) # :nodoc:
  q.text sprintf("#<data %s:...>", PP.mcall(self, Kernel, :class).name)
end