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



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

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



72
73
74
75
# File 'lib/rbbt/tsv/serializers.rb', line 72

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