Class: NeuralEntity
- Inherits:
-
Object
- Object
- NeuralEntity
- Defined in:
- lib/Yinspire/Core/NeuralEntity.rb,
lib/Yinspire.rb,
lib/Yinspire/Core/Scheduling/NeuralEntity.rb
Overview
Extends class NeuralEntity for methods related to scheduling.
Constant Summary collapse
- @@entity_type_map =
Entity type name to class mapping.
Hash.new
- @@entity_type_map_reverse =
Entity class to type name mapping.
Hash.new
- @@entity_ann_load_cache =
Annotation cache for loading entities.
Hash.new
- @@entity_ann_dump_cache =
Annotation cache for dumping entities.
Hash.new
Class Method Summary collapse
- .class_from_name(name) ⇒ Object
- .entity_ann_dump_cache ⇒ Object
- .entity_ann_load_cache ⇒ Object
- .entity_type_map ⇒ Object
- .entity_type_map_reverse ⇒ Object
- .new_from_name(name, *args, &block) ⇒ Object
Instance Method Summary collapse
-
#connect(target) ⇒ Object
Connect
self
withtarget
. -
#disconnect(target) ⇒ Object
Disconnect
self
from all connections. -
#disconnect_all ⇒ Object
Disconnect
self
from all connections. - #dump ⇒ Object
-
#each_connection ⇒ Object
Iterates over each connection.
- #entity_type ⇒ Object
-
#initialize(id = nil, simulator = nil, &block) ⇒ NeuralEntity
constructor
A new instance of NeuralEntity.
- #load(hash) ⇒ Object
Constructor Details
#initialize(id = nil, simulator = nil, &block) ⇒ NeuralEntity
Returns a new instance of NeuralEntity.
62 63 64 65 66 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 62 def initialize(id=nil, simulator=nil, &block) self.id = id self.simulator = simulator block.call(self) if block end |
Class Method Details
.class_from_name(name) ⇒ Object
41 42 43 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 41 def self.class_from_name(name) (@@entity_type_map[name] || raise(ArgumentError)) end |
.entity_ann_dump_cache ⇒ Object
35 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 35 def self.entity_ann_dump_cache() @@entity_ann_dump_cache end |
.entity_ann_load_cache ⇒ Object
29 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 29 def self.entity_ann_load_cache() @@entity_ann_load_cache end |
.entity_type_map ⇒ Object
14 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 14 def self.entity_type_map() @@entity_type_map end |
.entity_type_map_reverse ⇒ Object
21 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 21 def self.entity_type_map_reverse() @@entity_type_map_reverse end |
.new_from_name(name, *args, &block) ⇒ Object
37 38 39 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 37 def self.new_from_name(name, *args, &block) (@@entity_type_map[name] || raise(ArgumentError)).new(*args, &block) end |
Instance Method Details
#connect(target) ⇒ Object
Connect self
with target
.
88 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 88 def connect(target) raise "abstract method" end |
#disconnect(target) ⇒ Object
Disconnect self
from all connections.
93 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 93 def disconnect(target) raise "abstract method" end |
#disconnect_all ⇒ Object
Disconnect self
from all connections.
103 104 105 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 103 def disconnect_all each_connection {|conn| disconnect(conn) } end |
#dump ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 54 def dump hash = Hash.new @@entity_ann_dump_cache[self.class].each {|key| hash[key] = send(key) } hash end |
#each_connection ⇒ Object
Iterates over each connection. To be overwritten by subclasses!
98 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 98 def each_connection() raise "abstract method" end |
#entity_type ⇒ Object
23 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 23 def entity_type() @@entity_type_map_reverse[self.class] end |
#load(hash) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/Yinspire/Core/NeuralEntity.rb', line 45 def load(hash) a = @@entity_ann_load_cache[self.class] hash.each {|key, value| if meth = a[key] send(meth, value) end } end |