Class: FCSParse::FCSEvent
- Inherits:
-
Object
- Object
- FCSParse::FCSEvent
- Defined in:
- lib/fcsparse/fcsevent.rb
Overview
Class representing a single FCS-encoded event.
Constant Summary collapse
- DefaultDelimiter =
default delimiter for printing output
","
Class Method Summary collapse
-
.new_with_data_and_format(event_data_string, event_format_string, parameter_info_hash) ⇒ FCSEvent
Creates a new FCSEvent from the specified information.
Instance Method Summary collapse
-
#[](parameter_name) ⇒ FCSParam
Gets a named parameter associated with the event.
-
#[]=(parameter_name, value) ⇒ Object
Sets a named parameter associated with the event.
-
#initialize ⇒ FCSEvent
constructor
A new instance of FCSEvent.
-
#names_to_s_delim(delimiter) ⇒ String
Gets the names of the parameters associated with this event in alphabetical order as a string, delimited by the supplied delimiter.
-
#to_s ⇒ String
Converts the event to a string representation.
-
#to_s_delim(delimiter) ⇒ String
Gets the values of the parameters associated with this event ordered alphabetically by the parameter names (i.e. in the same order as when calling #names_to_s_delim), delimited by the supplied delimiter.
Constructor Details
#initialize ⇒ FCSEvent
Returns a new instance of FCSEvent.
75 76 77 78 79 |
# File 'lib/fcsparse/fcsevent.rb', line 75 def initialize @values = Hash.new end |
Class Method Details
.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 |
Instance Method Details
#[](parameter_name) ⇒ FCSParam
Gets a named parameter associated with the event.
149 150 151 152 153 |
# File 'lib/fcsparse/fcsevent.rb', line 149 def [](parameter_name) @values[parameter_name] end |
#[]=(parameter_name, value) ⇒ Object
Sets a named parameter associated with the event.
162 163 164 165 166 |
# File 'lib/fcsparse/fcsevent.rb', line 162 def []=(parameter_name, value) @values[parameter_name]= value end |
#names_to_s_delim(delimiter) ⇒ String
Gets the names of the parameters associated with this event in alphabetical order as a string, delimited by the supplied delimiter.
175 176 177 178 179 180 181 |
# File 'lib/fcsparse/fcsevent.rb', line 175 def names_to_s_delim(delimiter) all_param_names = @values.keys.sort all_param_names.join(delimiter) end |
#to_s ⇒ String
Converts the event to a string representation. This is the same as calling #to_s_delim with the delimiter set to DefaultDelimiter.
207 208 209 210 211 |
# File 'lib/fcsparse/fcsevent.rb', line 207 def to_s to_s_delim(DefaultDelimiter) end |
#to_s_delim(delimiter) ⇒ String
Gets the values of the parameters associated with this event ordered alphabetically by the parameter names (i.e. in the same order as when calling #names_to_s_delim), delimited by the supplied delimiter.
191 192 193 194 195 196 197 198 199 |
# File 'lib/fcsparse/fcsevent.rb', line 191 def to_s_delim(delimiter) all_param_names = @values.keys.sort all_param_values = all_param_names.map{|e| @values[e].value} all_param_values.join(delimiter) end |