Class: RMXWeakHolder

Inherits:
Object
  • Object
show all
Defined in:
lib/motion/RMXWeakHolder.rb

Instance Method Summary collapse

Constructor Details

#initialize(_value = nil) ⇒ RMXWeakHolder

Returns a new instance of RMXWeakHolder.



3
4
5
6
7
8
# File 'lib/motion/RMXWeakHolder.rb', line 3

def initialize(_value=nil)
  @value_desc = _value.rmx_object_desc
  @holder = NSHashTable.weakObjectsHashTable
  self.value = _value
  self
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/motion/RMXWeakHolder.rb', line 24

def eql?(other)
  other.hash == value.hash
end

#hashObject



20
21
22
# File 'lib/motion/RMXWeakHolder.rb', line 20

def hash
  value.hash
end

#inspectObject



28
29
30
31
32
33
34
# File 'lib/motion/RMXWeakHolder.rb', line 28

def inspect
  if val = value
    "(weak)#{@value_desc}"
  else
    "(deallocated)#{@value_desc}"
  end
end

#valueObject



10
11
12
# File 'lib/motion/RMXWeakHolder.rb', line 10

def value
  @holder.anyObject
end

#value=(_value) ⇒ Object



14
15
16
17
18
# File 'lib/motion/RMXWeakHolder.rb', line 14

def value=(_value)
  @holder.removeAllObjects
  @holder.addObject(_value) unless _value.nil?
  _value
end