Class: Cheri::Explorer::ObjectRec
- Inherits:
-
Object
- Object
- Cheri::Explorer::ObjectRec
- Defined in:
- lib/cheri/explorer/explorer.rb
Direct Known Subclasses
Constant Summary collapse
- MaxDataLength =
TODO: make this configurable (or settable in search dialog)
100000
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #ancestors ⇒ Object
- #clazz ⇒ Object
- #id ⇒ Object
-
#initialize(obj) ⇒ ObjectRec
constructor
A new instance of ObjectRec.
- #superclazz ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object
- #vars ⇒ Object
Constructor Details
#initialize(obj) ⇒ ObjectRec
Returns a new instance of ObjectRec.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cheri/explorer/explorer.rb', line 85 def initialize(obj) @z = obj.class.to_s rescue nil @i = obj.__id__ rescue nil if obj.respond_to?(:instance_variables) && (vars = (obj.instance_variables rescue nil)) && !vars.empty? @v = [] vars.each do |v| value = obj.instance_variable_get(v.to_sym) rescue nil type = value.class rescue nil @v << NameTypeValue.new(v,type,value) end end if obj.respond_to?(:ancestors) && (a = obj.ancestors rescue nil) @a = Array.new(a.length) {|i| ValueType.new(a[i]) } end @u = (obj.superclass.to_s rescue nil) if obj.respond_to?(:superclass) @s = obj.inspect rescue nil # we're going allow a maximum of ~ 64K for value @s = @s[0,MaxDataLength] << '...' if @s && @s.length > MaxDataLength end |
Instance Method Details
#<=>(other) ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/cheri/explorer/explorer.rb', line 122 def <=>(other) if ObjectRec === other value <=> other.value else value <=> (other.to_s rescue '') end end |
#ancestors ⇒ Object
119 120 121 |
# File 'lib/cheri/explorer/explorer.rb', line 119 def ancestors @a end |
#clazz ⇒ Object
104 105 106 |
# File 'lib/cheri/explorer/explorer.rb', line 104 def clazz @z end |
#id ⇒ Object
110 111 112 |
# File 'lib/cheri/explorer/explorer.rb', line 110 def id @i end |
#superclazz ⇒ Object
107 108 109 |
# File 'lib/cheri/explorer/explorer.rb', line 107 def superclazz @u end |
#to_s ⇒ Object
129 130 131 |
# File 'lib/cheri/explorer/explorer.rb', line 129 def to_s @s || '' end |
#value ⇒ Object
113 114 115 |
# File 'lib/cheri/explorer/explorer.rb', line 113 def value @s end |
#vars ⇒ Object
116 117 118 |
# File 'lib/cheri/explorer/explorer.rb', line 116 def vars @v end |