Class: TkInspect::Inspector::Base

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



33
34
35
36
37
38
39
# File 'lib/tk_inspect/inspector/base.rb', line 33

def initialize(options = {})
  @expression = options[:expression]
  @inspected_binding = options[:binding] || binding
  @value = options[:value]
  @tk_root = nil
  @main_component = nil
end

Instance Attribute Details

#expressionObject

Returns the value of attribute expression.



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

def expression
  @expression
end

#inspected_bindingObject

Returns the value of attribute inspected_binding.



9
10
11
# File 'lib/tk_inspect/inspector/base.rb', line 9

def inspected_binding
  @inspected_binding
end

#main_componentObject

Returns the value of attribute main_component.



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

def main_component
  @main_component
end

#tk_rootObject

Returns the value of attribute tk_root.



11
12
13
# File 'lib/tk_inspect/inspector/base.rb', line 11

def tk_root
  @tk_root
end

Class Method Details

.inspector_for_class(klass) ⇒ Object



22
23
24
25
26
27
# File 'lib/tk_inspect/inspector/base.rb', line 22

def self.inspector_for_class(klass)
  while klass && !(inspector = custom_inspectors[klass]) do
    klass = klass.superclass
  end
  inspector || self
end

.inspector_for_object(obj) ⇒ Object



29
30
31
# File 'lib/tk_inspect/inspector/base.rb', line 29

def self.inspector_for_object(obj)
  self.inspector_for_class(obj.class)
end

.register_shared_inspector(inspector_class, inspected_class) ⇒ Object



18
19
20
# File 'lib/tk_inspect/inspector/base.rb', line 18

def self.register_shared_inspector(inspector_class, inspected_class)
  custom_inspectors[inspected_class] = inspector_class
end

.shared_inspectorObject



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

def self.shared_inspector
  shared_inspector ||= self.new
end

Instance Method Details

#browse_class(class_name) ⇒ Object



52
53
54
55
56
57
# File 'lib/tk_inspect/inspector/base.rb', line 52

def browse_class(class_name)
  class_browser = TkInspect::ClassBrowser::Base.new
  class_browser.select_class_name(class_name)
  class_browser.refresh
  class_browser.show_current_path
end

#create_main_componentObject



59
60
61
# File 'lib/tk_inspect/inspector/base.rb', line 59

def create_main_component
  @main_component = RootComponent.new
end

#create_rootObject



45
46
47
48
49
50
# File 'lib/tk_inspect/inspector/base.rb', line 45

def create_root
  @tk_root = TkComponent::Window.new(title: window_title)
  create_main_component
  @main_component.inspector = self
  @tk_root.place_root_component(@main_component)
end

#refreshObject



41
42
43
# File 'lib/tk_inspect/inspector/base.rb', line 41

def refresh
  @main_component.nil? ? create_root : @main_component.regenerate
end

#window_titleObject



63
64
65
# File 'lib/tk_inspect/inspector/base.rb', line 63

def window_title
  "Inspector"
end