class Qa::Authorities::MeshTools::MeshDataParser
Attributes
file[RW]
Public Class Methods
new(file)
click to toggle source
# File lib/qa/authorities/mesh_tools/mesh_data_parser.rb, line 6 def initialize(file) @file = file end
Public Instance Methods
all_records()
click to toggle source
# File lib/qa/authorities/mesh_tools/mesh_data_parser.rb, line 33 def all_records result = [] each_mesh_record { |rec| result << rec } result end
each_mesh_record() { |current_data| ... }
click to toggle source
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/CyclomaticComplexity
# File lib/qa/authorities/mesh_tools/mesh_data_parser.rb, line 12 def each_mesh_record current_data = {} in_record = false file.each_line do |line| case line when /\A\*NEWRECORD/ yield(current_data) if in_record in_record = true current_data = {} when /\A(?<term>[^=]+) = (?<value>.*)/ current_data[Regexp.last_match(:term)] ||= [] current_data[Regexp.last_match(:term)] << Regexp.last_match(:value).strip when /\A\n/ yield(current_data) if in_record in_record = false end end # final time in case file did not end with a blank line yield(current_data) if in_record end