Class: Cheri::Explorer::ObjectRec

Inherits:
Object
  • Object
show all
Defined in:
lib/cheri/explorer/explorer.rb

Direct Known Subclasses

ConstRec

Constant Summary collapse

MaxDataLength =

TODO: make this configurable (or settable in search dialog)

100000

Instance Method Summary collapse

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

#ancestorsObject



119
120
121
# File 'lib/cheri/explorer/explorer.rb', line 119

def ancestors
  @a  
end

#clazzObject



104
105
106
# File 'lib/cheri/explorer/explorer.rb', line 104

def clazz
  @z  
end

#idObject



110
111
112
# File 'lib/cheri/explorer/explorer.rb', line 110

def id
  @i  
end

#superclazzObject



107
108
109
# File 'lib/cheri/explorer/explorer.rb', line 107

def superclazz
  @u  
end

#to_sObject



129
130
131
# File 'lib/cheri/explorer/explorer.rb', line 129

def to_s
  @s || ''
end

#valueObject



113
114
115
# File 'lib/cheri/explorer/explorer.rb', line 113

def value
  @s  
end

#varsObject



116
117
118
# File 'lib/cheri/explorer/explorer.rb', line 116

def vars
  @v  
end