Class: Tolerances

Inherits:
Object
  • Object
show all
Defined in:
lib/tolerances.rb

Constant Summary collapse

VERSION =
'1.0.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Tolerances

Returns a new instance of Tolerances.



9
10
11
12
13
14
15
16
17
# File 'lib/tolerances.rb', line 9

def initialize( contents )
  @contents = contents
  @tolerances = []
  @template = ''
  @tags = Hash.new{ |h,k| h[k]=[] }
  find_tolerances
  create_template
  collect_tags
end

Instance Attribute Details

#tagsObject (readonly)

Returns the value of attribute tags.



7
8
9
# File 'lib/tolerances.rb', line 7

def tags
  @tags
end

#tolerancesObject (readonly)

Returns the value of attribute tolerances.



7
8
9
# File 'lib/tolerances.rb', line 7

def tolerances
  @tolerances
end

Instance Method Details

#result(values) ⇒ Object



34
35
36
# File 'lib/tolerances.rb', line 34

def result( values )
  @template % values
end

#values_at(samples) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/tolerances.rb', line 23

def values_at( samples )
  if samples.size != tags.size
    raise "samples (#{samples.size}) != tags (#{@tags.size})"
  end
  values = []
  @tolerances.each_with_index do |tol,i|
    values << tol.value_at( samples[tol.sample_index] )
  end
  values
end