Class: Looksee::Help

Inherits:
Object show all
Defined in:
lib/looksee/shortcuts.rb

Instance Method Summary collapse

Instance Method Details

#inspectObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/looksee/shortcuts.rb', line 65

def inspect
  <<-EOS.gsub(/^ *\|/, '')
    |== Looksee Quick Reference
    |
    |  lp(object)
    |  object.lookup_path
    |    Print the method lookup path of \`object\'
    |
    |  lpi(klass)
    |    Print the method lookup path of an instance of \`klass\'.
    |
    |Add .grep(/pattern/) to restrict the methods listed:
    |
    |  lp(object).grep(/foo/)
    |
    |== Visibilities
    |
    |Methods are printed according to their visibility:
    |
    |#{style_info}
    |
    |Pass options to specify which visibilities to show:
    |
    |  lp(object, :private => true, :overridden => false)
    |  lp(object, :private        , :overridden => false)  # shortcut
  EOS
end

#style_infoObject



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/looksee/shortcuts.rb', line 93

def style_info
  max_width = 0
  styles = [:public, :protected, :private, :undefined, :overridden]
  data = styles.map do |name|
    display_style = Looksee.styles[name] % name
    display_length = display_style.length
    max_width = display_length if display_length > max_width
    on = Looksee.default_lookup_path_options[name] ? 'on' : 'off'
    [display_style, on]
  end.map do |display_style, on|
    "  * #{display_style.ljust(max_width)}  (#{on} by default)"
  end.join("\n")
end