Class: ViennaRna::Batch

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/vienna_rna/modules/batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#collectionObject (readonly)

Returns the value of attribute collection.



5
6
7
# File 'lib/vienna_rna/modules/batch.rb', line 5

def collection
  @collection
end

#typeObject (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

#eachObject



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