module CooCoo::LayerFactory

Attributes

types[R]

Public Class Methods

find_type(name) click to toggle source
# File lib/coo-coo/layer_factory.rb, line 12
def find_type(name)
  @types && @types[name]
end
from_hash(h, network = nil) click to toggle source
# 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) click to toggle source
# File lib/coo-coo/layer_factory.rb, line 6
def register_type(klass)
  @types ||= Hash.new
  @types[klass.name.to_s] = klass
  @types
end