Class: ViennaRna::Package::EnergyGrid2d::Row2d
- Inherits:
-
Object
- Object
- ViennaRna::Package::EnergyGrid2d::Row2d
- Defined in:
- lib/vienna_rna/package/energy_grid_2d.rb
Instance Attribute Summary collapse
-
#ensemble ⇒ Object
readonly
Returns the value of attribute ensemble.
-
#i ⇒ Object
readonly
Returns the value of attribute i.
-
#j ⇒ Object
readonly
Returns the value of attribute j.
-
#p ⇒ Object
readonly
Returns the value of attribute p.
Instance Method Summary collapse
- #<=>(other_row) ⇒ Object
-
#initialize(i, j, p, ensemble) ⇒ Row2d
constructor
A new instance of Row2d.
- #inspect ⇒ Object
- #position ⇒ Object
- #to_csv(energy_term: :p) ⇒ Object
Constructor Details
#initialize(i, j, p, ensemble) ⇒ Row2d
Returns a new instance of Row2d.
19 20 21 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 19 def initialize(i, j, p, ensemble) @i, @j, @p, @ensemble = i.to_i, j.to_i, BigDecimal.new(p.to_s), BigDecimal.new(ensemble.to_s) end |
Instance Attribute Details
#ensemble ⇒ Object (readonly)
Returns the value of attribute ensemble.
17 18 19 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 17 def ensemble @ensemble end |
#i ⇒ Object (readonly)
Returns the value of attribute i.
17 18 19 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 17 def i @i end |
#j ⇒ Object (readonly)
Returns the value of attribute j.
17 18 19 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 17 def j @j end |
#p ⇒ Object (readonly)
Returns the value of attribute p.
17 18 19 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 17 def p @p end |
Instance Method Details
#<=>(other_row) ⇒ Object
27 28 29 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 27 def <=>(other_row) i == other_row.i ? j <=> other_row.j : i <=> other_row.i end |
#inspect ⇒ Object
35 36 37 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 35 def inspect "#<Row2d (%d, %d), p: %s, ensemble: %s>" % [i, j, p, ensemble] end |
#position ⇒ Object
23 24 25 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 23 def position [i, j] end |
#to_csv(energy_term: :p) ⇒ Object
31 32 33 |
# File 'lib/vienna_rna/package/energy_grid_2d.rb', line 31 def to_csv(energy_term: :p) "%d,%d,%.8f" % [i, j, instance_variable_get(:"@#{energy_term}")] end |