Module: Looksee::ObjectMixin
- Defined in:
- lib/looksee/core_ext.rb
Instance Method Summary collapse
-
#edit(name) ⇒ Object
Open an editor at the named method’s definition.
-
#ls(*args) ⇒ Object
Return a Looksee::Inspector for this object.
Instance Method Details
#edit(name) ⇒ Object
Open an editor at the named method’s definition.
Uses Looksee.editor to determine the editor command to run.
Only works for methods for which file and line numbers are accessible.
53 54 55 |
# File 'lib/looksee/core_ext.rb', line 53 def edit(name) Editor.new(Looksee.editor).edit(self, name) end |
#ls(*args) ⇒ Object
Return a Looksee::Inspector for this object.
args
is an optional list of specifiers.
* +:public+ - include public methods
* +:protected+ - include public methods
* +:private+ - include public methods
* +:undefined+ - include public methods (see Module#undef_method)
* +:overridden+ - include public methods
* +:nopublic+ - include public methods
* +:noprotected+ - include public methods
* +:noprivate+ - include public methods
* +:noundefined+ - include public methods (see Module#undef_method)
* +:nooverridden+ - include public methods
* a string - only include methods containing this string (may
be used multiple times)
* a regexp - only include methods matching this regexp (may
be used multiple times)
The default (if options is nil or omitted) is given by #default_lookup_path_options.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/looksee/core_ext.rb', line 26 def ls(*args) = {:visibilities => Set[], :filters => Set[]} (Looksee.default_specifiers + args).each do |arg| case arg when String, Regexp [:filters] << arg when :public, :protected, :private, :undefined, :overridden [:visibilities].add(arg) when :nopublic, :noprotected, :noprivate, :noundefined, :nooverridden visibility = arg.to_s.sub(/\Ano/, '').to_sym [:visibilities].delete(visibility) else raise ArgumentError, "invalid specifier: #{arg.inspect}" end end lookup_path = LookupPath.new(self) Inspector.new(lookup_path, ) end |