Class: ViennaRna::Package::EnergyGrid2d::Row2d

Inherits:
Object
  • Object
show all
Defined in:
lib/vienna_rna/package/energy_grid_2d.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

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

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

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

#inspectObject



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

#positionObject



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