Class: Steps

Inherits:
Object
  • Object
show all
Defined in:
lib/topas-tools/Metarefine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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