Class: SPNet::BlockState
- Inherits:
-
Object
- Object
- SPNet::BlockState
- Includes:
- Hashmake::HashMakeable
- Defined in:
- lib/spnet/storage/block_state.rb
Overview
Represent a Block object using only serializeable objects.
Constant Summary collapse
- ARG_SPECS =
Define arg specs to use in processing hashed arguments during #initialize.
{ :class_sym => arg_spec(:reqd => true, :type => Symbol), :params => arg_spec_hash(:reqd => false, :type => Object), }
Instance Attribute Summary collapse
-
#class_sym ⇒ Object
readonly
Returns the value of attribute class_sym.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(args) ⇒ BlockState
constructor
A new instance of NetworkState.
-
#make_block(args) ⇒ Object
Produce a Block object from the current BlockState object.
Constructor Details
#initialize(args) ⇒ BlockState
A new instance of NetworkState.
20 21 22 |
# File 'lib/spnet/storage/block_state.rb', line 20 def initialize args hash_make args, BlockState::ARG_SPECS end |
Instance Attribute Details
#class_sym ⇒ Object (readonly)
Returns the value of attribute class_sym.
15 16 17 |
# File 'lib/spnet/storage/block_state.rb', line 15 def class_sym @class_sym end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
15 16 17 |
# File 'lib/spnet/storage/block_state.rb', line 15 def params @params end |
Instance Method Details
#make_block(args) ⇒ Object
Produce a Block object from the current BlockState object.
25 26 27 28 29 30 31 32 33 |
# File 'lib/spnet/storage/block_state.rb', line 25 def make_block args raise ArgumentError, "args does not have :sample_rate key" unless args.has_key?(:sample_rate) klass = find_class(@class_sym) block = klass.new :sample_rate => args[:sample_rate] block.restore_state self return block end |