class Array
Monkey patching Array
to add convert_types
method.
Public Instance Methods
convert_types(types)
click to toggle source
Method that converts variable types given an array of types. Example: [“fish”, 0.0, 1].convert_types([:to_s, :to_f, :to_i])
# File lib/BioDSL/csv.rb, line 32 def convert_types(types) if size != types.size fail ArgumentError, "Array and types size mismatch: #{size} != " \ "#{types.size}" end types.each_with_index do |type, i| self[i] = self[i].send(type) end self end