Sha256: 50794e67c4c7d608df155610fcdc92849cc3a1d38d77e2b5ada12194a8772c85
Contents?: true
Size: 772 Bytes
Versions: 4
Compression:
Stored size: 772 Bytes
Contents
module Enumerable # # Convert an array of values to a string representing it as a pig tuple # def to_pig_tuple '(' + self.join(',') + ')' end # # Convert an array of values to a string pig format # see also to_pig_bag # def to_pig *args to_pig_tuple *args end # # Convert an array of values to a string representing it as a pig bag # def to_pig_bag '{' + self.map{|*vals| vals.to_pig_tuple}.join(",") + '}' end # # Convert a string representing a pig bag into a nested array # def from_pig_bag self.split("),(").map{|t| t.gsub(/[\{\}]/, '').from_pig_tuple} rescue [] end # # Convert a string representing a pig tuple into an array # def from_pig_tuple self.gsub(/[\(\)]/, '').split(',') end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
wukong-3.0.0.pre | old/wukong/and_pig.rb |
wukong-2.0.2 | lib/wukong/and_pig.rb |
wukong-2.0.1 | lib/wukong/and_pig.rb |
wukong-2.0.0 | lib/wukong/and_pig.rb |