Class: TkInspect::Inspector::Base
- Defined in:
- lib/tk_inspect/inspector/base.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#inspected_binding ⇒ Object
Returns the value of attribute inspected_binding.
-
#main_component ⇒ Object
Returns the value of attribute main_component.
-
#tk_root ⇒ Object
Returns the value of attribute tk_root.
Class Method Summary collapse
- .inspector_for_class(klass) ⇒ Object
- .inspector_for_object(obj) ⇒ Object
- .register_shared_inspector(inspector_class, inspected_class) ⇒ Object
- .shared_inspector ⇒ Object
Instance Method Summary collapse
- #browse_class(class_name) ⇒ Object
- #create_main_component ⇒ Object
- #create_root ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #refresh ⇒ Object
- #window_title ⇒ Object
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( = {}) @expression = [:expression] @inspected_binding = [:binding] || binding @value = [:value] @tk_root = nil @main_component = nil end |
Instance Attribute Details
#expression ⇒ Object
Returns the value of attribute expression.
10 11 12 |
# File 'lib/tk_inspect/inspector/base.rb', line 10 def expression @expression end |
#inspected_binding ⇒ Object
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_component ⇒ Object
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_root ⇒ Object
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_inspector ⇒ Object
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_component ⇒ Object
59 60 61 |
# File 'lib/tk_inspect/inspector/base.rb', line 59 def create_main_component @main_component = RootComponent.new end |
#create_root ⇒ Object
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 |
#refresh ⇒ Object
41 42 43 |
# File 'lib/tk_inspect/inspector/base.rb', line 41 def refresh @main_component.nil? ? create_root : @main_component.regenerate end |
#window_title ⇒ Object
63 64 65 |
# File 'lib/tk_inspect/inspector/base.rb', line 63 def window_title "Inspector" end |