Class: TSV::StringDoubleArraySerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/rbbt/tsv/serializers.rb

Class Method Summary collapse

Class Method Details

.dump(array) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/rbbt/tsv/serializers.rb', line 58

def self.dump(array)
  begin
  array.collect{|a| a.collect{|a| a.to_s } * "|"} * "\t"
  rescue Encoding::CompatibilityError
    array.collect{|a| a.collect{|a| a.to_s.force_encoding('UTF-8')} * "|"} * "\t"
  end
end

.load(string) ⇒ Object



66
67
68
69
# File 'lib/rbbt/tsv/serializers.rb', line 66

def self.load(string)
  return [] if string.nil?
  string.split("\t", -1).collect{|l| l.split("|", -1)}
end