Module: CooCoo::LayerFactory
- Defined in:
- lib/coo-coo/layer_factory.rb
Class Attribute Summary collapse
-
.types ⇒ Object
readonly
Returns the value of attribute types.
Class Method Summary collapse
Class Attribute Details
.types ⇒ Object (readonly)
Returns the value of attribute types.
4 5 6 |
# File 'lib/coo-coo/layer_factory.rb', line 4 def types @types end |
Class Method Details
.find_type(name) ⇒ Object
12 13 14 |
# File 'lib/coo-coo/layer_factory.rb', line 12 def find_type(name) @types && @types[name] end |
.from_hash(h, network = nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/coo-coo/layer_factory.rb', line 16 def from_hash(h, network = nil) klass = find_type(h[:type]) if klass klass.from_hash(h, network) else raise ArgumentError.new("invalid layer type #{h[:type].inspect}") end end |
.register_type(klass) ⇒ Object
6 7 8 9 10 |
# File 'lib/coo-coo/layer_factory.rb', line 6 def register_type(klass) @types ||= Hash.new @types[klass.name.to_s] = klass @types end |