Class: Steps
- Inherits:
-
Object
- Object
- Steps
- Defined in:
- lib/topas-tools/Metarefine.rb
Instance Attribute Summary collapse
-
#k1s ⇒ Object
readonly
Returns the value of attribute k1s.
Instance Method Summary collapse
- #get_k1s(points, stepsizes) ⇒ Object
-
#initialize(ps, ss) ⇒ Steps
constructor
A new instance of Steps.
Constructor Details
#initialize(ps, ss) ⇒ Steps
Returns a new instance of Steps.
2 3 4 5 6 |
# File 'lib/topas-tools/Metarefine.rb', line 2 def initialize ps, ss ss.empty? && raise("Empty steps!") (ps.size == (ss.size + 1) ) || raise("Inconsistent points and steps: #{ps}, #{ss}") @k1s = get_k1s ps, ss end |
Instance Attribute Details
#k1s ⇒ Object (readonly)
Returns the value of attribute k1s.
7 8 9 |
# File 'lib/topas-tools/Metarefine.rb', line 7 def k1s @k1s end |
Instance Method Details
#get_k1s(points, stepsizes) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/topas-tools/Metarefine.rb', line 8 def get_k1s points, stepsizes stepsizes.reduce([]){|result, stepsize| a = result + points[0].step(points[1] ,-stepsize.to_f).to_a + [points[1].to_f] points.shift a}.uniq end |