Class: Twisty::Entity
- Inherits:
-
Object
- Object
- Twisty::Entity
- 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.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
(
Symbol)The Symbol used to distinguish the Entity from other memebers of the same sub-class.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(
Boolean). -
#clone(other) ⇒ Object
Creates an identical instance of the Entity.
-
#engine ⇒ Object
(
Engine).
Instance Attribute Details
#id ⇒ Object (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 |
#engine ⇒ Object
(Engine)
Convinience class to access the Engine
56 57 58 |
# File 'lib/twisty/entity.rb', line 56 def engine return Engine.instance() end |