Class: Looksee::Inspector
- Inherits:
-
Object
- Object
- Looksee::Inspector
- Defined in:
- lib/looksee/inspector.rb
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#lookup_path ⇒ Object
readonly
Returns the value of attribute lookup_path.
-
#visibilities ⇒ Object
readonly
Returns the value of attribute visibilities.
Instance Method Summary collapse
-
#edit(name) ⇒ Object
Open an editor at the named method’s definition.
-
#initialize(lookup_path, options = {}) ⇒ Inspector
constructor
A new instance of Inspector.
-
#inspect ⇒ Object
Print the method lookup path of self.
Constructor Details
#initialize(lookup_path, options = {}) ⇒ Inspector
Returns a new instance of Inspector.
3 4 5 6 7 8 |
# File 'lib/looksee/inspector.rb', line 3 def initialize(lookup_path, ={}) @lookup_path = lookup_path @visibilities = (vs = [:visibilities]) ? vs.to_set : Set[] @filters = (fs = [:filters]) ? fs.to_set : Set[] @width = [:width] || ENV['COLUMNS'].to_i.nonzero? || Looksee.default_width end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
12 13 14 |
# File 'lib/looksee/inspector.rb', line 12 def filters @filters end |
#lookup_path ⇒ Object (readonly)
Returns the value of attribute lookup_path.
10 11 12 |
# File 'lib/looksee/inspector.rb', line 10 def lookup_path @lookup_path end |
#visibilities ⇒ Object (readonly)
Returns the value of attribute visibilities.
11 12 13 |
# File 'lib/looksee/inspector.rb', line 11 def visibilities @visibilities end |
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.
31 32 33 |
# File 'lib/looksee/inspector.rb', line 31 def edit(name) Editor.new(Looksee.editor).edit(lookup_path.object, name) end |
#inspect ⇒ Object
Print the method lookup path of self. See the README for details.
17 18 19 20 21 |
# File 'lib/looksee/inspector.rb', line 17 def inspect lookup_path.entries.reverse.map do |entry| inspect_entry(entry) end.join("\n") end |