Class: Wrnap::Package::Base
- Inherits:
-
Object
- Object
- Wrnap::Package::Base
- Includes:
- Global::Chainer, Global::Runner, Global::Yaml
- Defined in:
- lib/wrnap/package/base.rb
Direct Known Subclasses
EnergyGrid2d, Eval, FftEqBase, FftMfpt, Fold, FoldConstrained, Heat, Kinwalker, Mfpt, Plot, Spectral, Subopt, TabuPath, Varna, Xbor
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#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.
- #inspect ⇒ Object
Methods included from Global::Yaml
Methods included from Global::Chainer
Methods included from Global::Runner
Constructor Details
#initialize(data, chaining: false) ⇒ Base
Returns a new instance of Base.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/wrnap/package/base.rb', line 38 def initialize(data, chaining: false) unless chaining data = [data] unless data.is_a?(Array) @data = case data.map(&:class) when [Wrnap::Rna], [Wrnap::Rna::Context] 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 Wrnap::Rna.placeholder else raise TypeError.new("Unsupported Wrnap::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.
36 37 38 |
# File 'lib/wrnap/package/base.rb', line 36 def data @data end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
36 37 38 |
# File 'lib/wrnap/package/base.rb', line 36 def flags @flags end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
36 37 38 |
# File 'lib/wrnap/package/base.rb', line 36 def response @response end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
36 37 38 |
# File 'lib/wrnap/package/base.rb', line 36 def runtime @runtime end |
Class Method Details
.bootstrap(data: nil, output: "") ⇒ Object
28 29 30 31 32 33 |
# File 'lib/wrnap/package/base.rb', line 28 def bootstrap(data: nil, output: "") new(data).tap do |object| object.instance_variable_set(:@response, File.exist?(output) ? File.read(output).chomp : output) object.post_process if object.respond_to?(:post_process) end end |
Instance Method Details
#debugger(&block) ⇒ Object
55 56 57 |
# File 'lib/wrnap/package/base.rb', line 55 def debugger(&block) self.class.debugger(&block) end |
#inspect ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/wrnap/package/base.rb', line 59 def inspect "#<%s (%.2f sec): data: %s, flags: %s, vars: %s>" % [ self.class.name, runtime.real, data, flags, (instance_variables - %i|@data @flags @response @runtime|).map(&:to_s).sort.join(", ") ] end |