class SPNet::NetworkState
Represents a Network
object using only serializeable objects.
@author James Tunnell
Constants
- ARG_SPECS
Define arg specs to use in processing hashed arguments during initialize.
Attributes
block_models[R]
link_models[R]
sample_rate[R]
Public Class Methods
new(args = {})
click to toggle source
A new instance of NetworkState
. @param [Hash] args Hashed arguments for initialization. See Network::ARG_SPECS
for details of which keys are required.
# File lib/spnet/storage/network_state.rb, line 20 def initialize args = {} hash_make args, NetworkState::ARG_SPECS end
Public Instance Methods
make_network(args)
click to toggle source
Produce a Network
object from the current NetworkState
object. @param [Hash] args Hashed arguments. The only key required is :sample_rate.
# File lib/spnet/storage/network_state.rb, line 26 def make_network args raise ArgumentError, "args does not have :sample_rate key" unless args.has_key?(:sample_rate) sample_rate = args[:sample_rate] blocks = {} @block_states.each do |block_name, block_state| blocks[block_name] = block_state.make_block :sample_rate => sample_rate end links = [] @link_states.each do |link_state| links.push link_state.make_link blocks end Network.new :blocks => blocks, :links => links, :sample_rate => sample_rate end