Class: Result
- Inherits:
-
Object
- Object
- Result
- Defined in:
- lib/ruby_astm/result.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dilution ⇒ Object
Returns the value of attribute dilution.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#name ⇒ Object
Returns the value of attribute name.
-
#reference_ranges ⇒ Object
Returns the value of attribute reference_ranges.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#units ⇒ Object
Returns the value of attribute units.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(args) ⇒ Result
constructor
here will call mappings and check the result correlation.
-
#lookup_mapping(name) ⇒ Object
@return the name defined in the mappings.json file, or the name that wqs passed in.
- #lookup_transform(name) ⇒ Object
- #set_dilution(args) ⇒ Object
- #set_flags(args) ⇒ Object
- #set_name(args) ⇒ Object
- #set_reference_ranges(args) ⇒ Object
- #set_timestamp(args) ⇒ Object
- #set_units(args) ⇒ Object
- #set_value(args) ⇒ Object
Constructor Details
#initialize(args) ⇒ Result
here will call mappings and check the result correlation
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ruby_astm/result.rb', line 62 def initialize(args) set_name(args) set_flags(args) set_value(args) (args) set_dilution(args) set_units(args) =begin 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 self.value = eval(transform_expression) end 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 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 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.
94 95 96 |
# File 'lib/ruby_astm/result.rb', line 94 def lookup_mapping(name) $mappings[name] ? $mappings[name]["LIS_CODE"] : name end |
#lookup_transform(name) ⇒ Object
98 99 100 |
# File 'lib/ruby_astm/result.rb', line 98 def lookup_transform(name) $mappings[name] ? $mappings[name]["TRANSFORM"] : nil end |
#set_dilution(args) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/ruby_astm/result.rb', line 53 def set_dilution(args) if line = args[:line] line.fields[2].scan(/\^+(?<name>[A-Za-z0-9\%\#\-\_\?\/]+)\^?(?<dilution>\d+)?/) { |name,dilution| self.dilution = dilution } end end |
#set_flags(args) ⇒ Object
29 30 31 32 33 |
# File 'lib/ruby_astm/result.rb', line 29 def set_flags(args) if line = args[:line] self.flags = line.fields[6].strip end end |
#set_name(args) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/ruby_astm/result.rb', line 10 def set_name(args) if line = args[:line] line.fields[2].scan(/\^+(?<name>[A-Za-z0-9\%\#\-\_\?\/]+)\^?(?<dilution>\d+)?/) { |name,dilution| self.name = lookup_mapping(name) } end end |
#set_reference_ranges(args) ⇒ Object
47 48 49 50 51 |
# File 'lib/ruby_astm/result.rb', line 47 def set_reference_ranges(args) if line = args[:line] self.reference_ranges = line.fields[5].strip end end |
#set_timestamp(args) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/ruby_astm/result.rb', line 39 def (args) if line = args[:line] 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. = Time.new(year,month,day,hours,minutes,seconds) } end end |
#set_units(args) ⇒ Object
35 36 37 |
# File 'lib/ruby_astm/result.rb', line 35 def set_units(args) end |
#set_value(args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby_astm/result.rb', line 18 def set_value(args) if line = args[:line] self.value = line.fields[3].strip line.fields[2].scan(/\^+(?<name>[A-Za-z0-9\%\#\-\_\?\/]+)\^?(?<dilution>\d+)?/) { |name,dilution| if transform_expression = lookup_transform(name) self.value = eval(transform_expression) end } end end |