Method: FCSParse::FCSEvent.new_with_data_and_format
- Defined in:
- lib/fcsparse/fcsevent.rb
.new_with_data_and_format(event_data_string, event_format_string, parameter_info_hash) ⇒ FCSEvent
Creates a new FCSEvent from the specified information.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/fcsparse/fcsevent.rb', line 96 def self.new_with_data_and_format(event_data_string, event_format_string, parameter_info_hash) data_points = event_data_string.unpack(event_format_string) parameter_names = Hash.new parameter_limits = Hash.new parameter_info_hash.each_key do |k| matchobj = k.to_s.match(T_ParameterNameKeywordRegex) if matchobj then parameter_names[matchobj[1].to_i] = parameter_info_hash[k] end matchobj = k.to_s.match(T_ParameterRangeKeywordRegex) if matchobj then parameter_limits[matchobj[1].to_i] = parameter_info_hash[k] end end ordered_indices = parameter_names.keys.sort event = new data_points.each_with_index do |e, i| param = FCSParam.new(parameter_names[ordered_indices[i]], nil, e, parameter_limits[ordered_indices[i]]) event[param.name] = param end event end |