Class: RubyWho

Inherits:
Object
  • Object
show all
Defined in:
lib/rubywho.rb

Overview

Author:

  • ongaeshi

Defined Under Namespace

Modules: Adapter

Constant Summary collapse

IGNORE =
[RubyWho::Adapter]
COLS =
80

Instance Method Summary collapse

Constructor Details

#initialize(obj, io, filter_re, kind) ⇒ RubyWho

Returns a new instance of RubyWho.



49
50
51
52
53
54
# File 'lib/rubywho.rb', line 49

def initialize(obj, io, filter_re, kind)
  @obj = obj
  @io = io
  @filter_re = filter_re.is_a?(String) ? Regexp.new(filter_re) : filter_re
  @kind = kind
end

Instance Method Details

#display(n = nil) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rubywho.rb', line 66

def display(n = nil)
  obj_klass = @obj.is_a?(Module) ? @obj : @obj.class

  if singleton?
    limit(obj_klass.ancestors, n).each do |klass|
      @io.puts klass.to_s + '(%s)' % klass.class
      display_methods(klass.singleton_methods(false))
    end
  else
    limit(obj_klass.ancestors, n).each do |klass|
      @io.puts klass.to_s + '#'
      display_methods(klass.public_instance_methods(false))
    end
  end
end

#obj_strObject



56
57
58
59
60
61
62
63
64
# File 'lib/rubywho.rb', line 56

def obj_str
  klass = @obj.is_a?(Module) ? @obj : @obj.class
  
  if singleton?
    klass.to_s + '(%s)' % klass.class
  else
    klass.to_s + '#'
  end
end