Class: Result

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Result

here will call mappings and check the result correlation



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ruby_astm/result.rb', line 11

def initialize(args)
	if args[:line]
		line = args[:line]
		transform_expression = nil
		line.fields[2].scan(/\^+(?<name>[A-Za-z0-9\%\#\-\_\?\/]+)\^?(?<dilution>\d+)?/) { |name,dilution|  
			self.name = lookup_mapping(name)
			self.dilution = dilution
			transform_expression = lookup_transform(name)
		}
		self.value = line.fields[3].strip
		
		if transform_expression
			#puts "got transform expression, now evalling it."
			self.value = eval(transform_expression)
			#puts "Value after eval: #{self.value}"
		end
		#eval(transform_expression) unless transform_expression.blank?
		self.reference_ranges = line.fields[5].strip
		self.flags = line.fields[6].strip 
		line.fields[12].strip.scan(/(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})(?<hours>\d{2})(?<minutes>\d{2})(?<seconds>\d{2})/) {|year,month,day,hours,minutes,seconds|
			self.timestamp = Time.new(year,month,day,hours,minutes,seconds)
		}
	else
		super
	end
end

Instance Attribute Details

#dilution ⇒ Object

Returns the value of attribute dilution.



8
9
10
# File 'lib/ruby_astm/result.rb', line 8

def dilution
  @dilution
end

#flags ⇒ Object

Returns the value of attribute flags.



5
6
7
# File 'lib/ruby_astm/result.rb', line 5

def flags
  @flags
end

#name ⇒ Object

Returns the value of attribute name.



2
3
4
# File 'lib/ruby_astm/result.rb', line 2

def name
  @name
end

#reference_ranges ⇒ Object

Returns the value of attribute reference_ranges.



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

def reference_ranges
  @reference_ranges
end

#timestamp ⇒ Object

Returns the value of attribute timestamp.



6
7
8
# File 'lib/ruby_astm/result.rb', line 6

def timestamp
  @timestamp
end

#units ⇒ Object

Returns the value of attribute units.



4
5
6
# File 'lib/ruby_astm/result.rb', line 4

def units
  @units
end

#value ⇒ Object

Returns the value of attribute value.



3
4
5
# File 'lib/ruby_astm/result.rb', line 3

def value
  @value
end

Instance Method Details

#lookup_mapping(name) ⇒ Object

@return the name defined in the mappings.json file, or the name that wqs passed in.



39
40
41
# File 'lib/ruby_astm/result.rb', line 39

def lookup_mapping(name)
	$mappings[name] ? $mappings[name]["LIS_CODE"] : name 
end

#lookup_transform(name) ⇒ Object



43
44
45
# File 'lib/ruby_astm/result.rb', line 43

def lookup_transform(name)
	$mappings[name] ? $mappings[name]["TRANSFORM"] : nil
end