Class: ViennaRna::Batch
- Inherits:
-
Object
- Object
- ViennaRna::Batch
- Includes:
- Enumerable
- Defined in:
- lib/vienna_rna/modules/batch.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(type, data) ⇒ Batch
constructor
A new instance of Batch.
- #run(flags = {}) ⇒ Object
Constructor Details
#initialize(type, data) ⇒ Batch
Returns a new instance of Batch.
7 8 9 10 |
# File 'lib/vienna_rna/modules/batch.rb', line 7 def initialize(type, data) @type = type @collection = data.map(&type.method(:new)) end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
5 6 7 |
# File 'lib/vienna_rna/modules/batch.rb', line 5 def collection @collection end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/vienna_rna/modules/batch.rb', line 5 def type @type end |
Instance Method Details
#each ⇒ Object
12 13 14 |
# File 'lib/vienna_rna/modules/batch.rb', line 12 def each collection.each { |element| yield element } end |
#run(flags = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/vienna_rna/modules/batch.rb', line 16 def run(flags = {}) tap do if (@memo ||= {})[flags] @memo[flags] else @memo[flags] = map { |element| element.run(flags) } end end end |