summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-17 16:52:59 +0200
committerPatrick Simianer <p@simianer.de>2014-06-17 16:52:59 +0200
commitf28694f9bdd5059050e420cca2ca2694cbb0dda4 (patch)
treefd07ef865a8e49fef0268850143a92f1d3b0f190 /lib
parent773f13eab521db5dadd993c00dc4c780970d5d2e (diff)
fix -> 1.0.3
Diffstat (limited to 'lib')
-rw-r--r--lib/zipf/SparseVector.rb10
1 files changed, 5 insertions, 5 deletions
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