Class: Looksee::Inspector

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @lookup_path = lookup_path
  @visibilities = (vs = options[:visibilities]) ? vs.to_set : Set[]
  @filters = (fs = options[:filters]) ? fs.to_set : Set[]
  @width = options[:width] || ENV['COLUMNS'].to_i.nonzero? || Looksee.default_width
end

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.



12
13
14
# File 'lib/looksee/inspector.rb', line 12

def filters
  @filters
end

#lookup_pathObject (readonly)

Returns the value of attribute lookup_path.



10
11
12
# File 'lib/looksee/inspector.rb', line 10

def lookup_path
  @lookup_path
end

#visibilitiesObject (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

#inspectObject

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