From f28694f9bdd5059050e420cca2ca2694cbb0dda4 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 17 Jun 2014 16:52:59 +0200 Subject: fix -> 1.0.3 --- lib/zipf/SparseVector.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/zipf/SparseVector.rb b/lib/zipf/SparseVector.rb index 33bb396..3f950c4 100644 --- a/lib/zipf/SparseVector.rb +++ b/lib/zipf/SparseVector.rb @@ -55,9 +55,9 @@ class SparseVector < Hash return a.join join end - def from_kv s - s.split.each { |i| - k,v = i.split('=') + def from_kv s, sep='=', join=/\s/ + s.split(join).each { |i| + k,v = i.split(sep) self[k] = v.to_f } end @@ -76,9 +76,9 @@ class SparseVector < Hash return v end - def self.from_kv s + def self.from_kv s, sep='=', join=/\s/ v = SparseVector.new - v.from_kv s + v.from_kv s, sep, join return v end -- cgit v1.2.3