Class: SPNet::NetworkState
- Inherits:
-
Object
- Object
- SPNet::NetworkState
- Includes:
- Hashmake::HashMakeable
- Defined in:
- lib/spnet/storage/network_state.rb
Overview
Represents a Network object using only serializeable objects.
Constant Summary collapse
- ARG_SPECS =
Define arg specs to use in processing hashed arguments during #initialize.
{ :block_states => arg_spec_hash(:reqd => false, :type => BlockState), :link_states => arg_spec_array(:reqd => false, :type => LinkState), }
Instance Attribute Summary collapse
-
#block_models ⇒ Object
readonly
Returns the value of attribute block_models.
-
#link_models ⇒ Object
readonly
Returns the value of attribute link_models.
-
#sample_rate ⇒ Object
readonly
Returns the value of attribute sample_rate.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ NetworkState
constructor
A new instance of NetworkState.
-
#make_network(args) ⇒ Object
Produce a Network object from the current NetworkState object.
Constructor Details
#initialize(args = {}) ⇒ NetworkState
A new instance of NetworkState.
20 21 22 |
# File 'lib/spnet/storage/network_state.rb', line 20 def initialize args = {} hash_make args, NetworkState::ARG_SPECS end |
Instance Attribute Details
#block_models ⇒ Object (readonly)
Returns the value of attribute block_models.
15 16 17 |
# File 'lib/spnet/storage/network_state.rb', line 15 def block_models @block_models end |
#link_models ⇒ Object (readonly)
Returns the value of attribute link_models.
15 16 17 |
# File 'lib/spnet/storage/network_state.rb', line 15 def link_models @link_models end |
#sample_rate ⇒ Object (readonly)
Returns the value of attribute sample_rate.
15 16 17 |
# File 'lib/spnet/storage/network_state.rb', line 15 def sample_rate @sample_rate end |
Instance Method Details
#make_network(args) ⇒ Object
Produce a Network object from the current NetworkState object.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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 |