Class: ViennaRna::Package::Base
- Inherits:
-
Object
- Object
- ViennaRna::Package::Base
- Includes:
- Global::ChainExtensions, Global::RunExtensions
- Defined in:
- lib/vienna_rna/package/base.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
Class Method Summary collapse
Instance Method Summary collapse
- #debugger(&block) ⇒ Object
-
#initialize(data, chaining: false) ⇒ Base
constructor
A new instance of Base.
- #serialize ⇒ Object
Methods included from Global::ChainExtensions
Methods included from Global::RunExtensions
Constructor Details
#initialize(data, chaining: false) ⇒ Base
Returns a new instance of Base.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vienna_rna/package/base.rb', line 33 def initialize(data, chaining: false) unless chaining data = [data] unless data.is_a?(Array) @data = case data.map(&:class) when [ViennaRna::Global::Rna] then data.first when *(1..3).map { |i| [String] * i } then RNA.from_string(*data) when [Hash] then RNA.from_hash(*data) when [Array] then RNA.from_array(*data) when [NilClass] then ViennaRna::Global::Rna.placeholder else raise TypeError.new("Unsupported ViennaRna::Global::Rna#initialize format: #{data}") end else @data = transform_for_chaining(data) end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
31 32 33 |
# File 'lib/vienna_rna/package/base.rb', line 31 def data @data end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
31 32 33 |
# File 'lib/vienna_rna/package/base.rb', line 31 def response @response end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
31 32 33 |
# File 'lib/vienna_rna/package/base.rb', line 31 def runtime @runtime end |
Class Method Details
.bootstrap(data: nil, output: "") ⇒ Object
24 25 26 27 28 |
# File 'lib/vienna_rna/package/base.rb', line 24 def bootstrap(data: nil, output: "") new(data).tap do |object| object.instance_variable_set(:@response, File.exist?(output) ? File.read(output).chomp : output) end end |
Instance Method Details
#debugger(&block) ⇒ Object
54 55 56 |
# File 'lib/vienna_rna/package/base.rb', line 54 def debugger(&block) self.class.debugger(&block) end |
#serialize ⇒ Object
50 51 52 |
# File 'lib/vienna_rna/package/base.rb', line 50 def serialize YAML.dump(self) end |