Class: VR::ObjectInspector::VariablesListView

Inherits:
ListView
  • Object
show all
Defined in:
lib/oinspect/VariablesListView.rb

Overview

Listview that holds variables in the ObjectInspectorGUI

Instance Attribute Summary

Attributes included from ViewCommon

#column_keys, #vr_cols, #vr_renderer

Attributes included from GladeGUI

#builder

Instance Method Summary collapse

Methods inherited from ListView

#[], #add_active_record_rows, #add_row, #before_show, #select_row

Methods included from ViewCommon

#col_attr, #column, #delete_selected, #each_renderer, #each_row, #flatten_hash, #get_iter, #id, #load_columns, #method_missing, #ren_attr, #renderer, #selected_rows, #turn_on_comboboxes, #vr_row

Methods included from GladeGUI

#buttonCancel__clicked, #extract_key, #fill_control, #get_control_value, #get_glade_active_record, #get_glade_all, #get_glade_variables, included, #load_glade, #parse_signals, #set_drag_drop, #set_glade_active_record, #set_glade_all, #set_glade_hash, #set_glade_variables, #show_glade, #try_to_select_text_in_combobox, #window1__destroy, #window1__key_press_event

Constructor Details

#initialize(obj) ⇒ VariablesListView

Returns a new instance of VariablesListView.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/oinspect/VariablesListView.rb', line 5

def initialize(obj)
  super(variable: String, type: String, class: String, value: String, obj: Object)
  obj.instance_variables.each do |var|
    row = add_row
    row[:variable] = var.to_s
    row[:class] = obj.instance_variable_get(var).class.name
    row[:value] = obj.instance_variable_get(var).to_s
    row[:type] = "var"
    row[:obj] = obj.instance_variable_get(var)
  end
  if obj.is_a?(Hash)
    obj.each do |key, val|
    row = add_row
    row[:variable] = key.to_s
    row[:class] = val.class.name
    row[:value] = val.to_s
    row[:type] = "key"
    row[:obj] = val
    end
  end
  if obj.is_a?(Array)
    obj.each_index do |i|
    row = add_row
    row[:variable] = i.to_s
    row[:class] = obj[i].class.name
    row[:value] = obj[i].to_s
    row[:type] = "index"
    row[:obj] = obj[i]
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class VR::ViewCommon