Class: Box2D::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/box2d/handle.rb

Direct Known Subclasses

Body, Chain, Joint, Shape

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(world, id) ⇒ Handle

Returns a new instance of Handle.



7
8
9
10
11
12
# File 'lib/box2d/handle.rb', line 7

def initialize(world, id)
  @world = world
  @id = ValueConversion.copy_struct(self.class::ID_CLASS, id)
  @key = ValueConversion.id_key(@id)
  @destroyed = false
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/box2d/handle.rb', line 5

def id
  @id
end

#worldObject (readonly)

Returns the value of attribute world.



5
6
7
# File 'lib/box2d/handle.rb', line 5

def world
  @world
end

Instance Method Details

#destroyed?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/box2d/handle.rb', line 18

def destroyed?
  !valid?
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


26
27
28
# File 'lib/box2d/handle.rb', line 26

def eql?(other)
  other.instance_of?(self.class) && other.world.equal?(@world) && other.key == @key
end

#hashObject



22
23
24
# File 'lib/box2d/handle.rb', line 22

def hash
  [self.class, @world.object_id, @key].hash
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/box2d/handle.rb', line 14

def valid?
  !@destroyed && @world.valid? && native_valid?
end