Class: Looksee::Inspector

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PrettyPrintHack

#pretty_print

Constructor Details

#initialize(lookup_path, options = {}) ⇒ Inspector

Returns a new instance of Inspector.



5
6
7
8
9
10
# File 'lib/looksee/inspector.rb', line 5

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.



14
15
16
# File 'lib/looksee/inspector.rb', line 14

def filters
  @filters
end

#lookup_pathObject (readonly)

Returns the value of attribute lookup_path.



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

def lookup_path
  @lookup_path
end

#visibilitiesObject (readonly)

Returns the value of attribute visibilities.



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

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.



33
34
35
# File 'lib/looksee/inspector.rb', line 33

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.



19
20
21
22
23
# File 'lib/looksee/inspector.rb', line 19

def inspect
  lookup_path.entries.reverse.map do |entry|
    inspect_entry(entry)
  end.join("\n")
end