Class: Twisty::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/twisty/entity.rb

Overview

Super-class of Room and Item. Do not use directly.

NOTE It is possible this class may be removed in future versions.

Direct Known Subclasses

Item, Room

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject (readonly)

(Symbol)The Symbol used to distinguish the Entity from other memebers of the same sub-class



26
27
28
# File 'lib/twisty/entity.rb', line 26

def id
  @id
end

Instance Method Details

#==(other) ⇒ Object

(Boolean)

Checks if two different instances of Entity refer to the same datum

other

(Entity) instance of Entity to check for equality against



34
35
36
37
38
39
40
41
42
# File 'lib/twisty/entity.rb', line 34

def ==(other)
  if other.class == self.class
    return other.id == @id
  elsif other.class == Symbol
    return other == @id
  else
    return false
  end
end

#clone(other) ⇒ Object

Creates an identical instance of the Entity

other

(Symbol) Index entry of the new instance



48
49
50
51
# File 'lib/twisty/entity.rb', line 48

def clone(other)
  raise GameError.new "Can not use Entity directly. Please use subclass instead"
  return nil
end

#engineObject

(Engine)

Convinience class to access the Engine



56
57
58
# File 'lib/twisty/entity.rb', line 56

def engine
  return Engine.instance()
end