cellar 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cellar.rb +15 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be9c519146063e4b17e8736dfd6d58f968411ef172c2c7ba4bb6f9f2669f7ebc
|
4
|
+
data.tar.gz: a030af0aaa876017a8ec86960aff3fb3f10d0265b8750b6a7f2fb8e14260f5ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d6004af8953418d4b3e76cc96fd7ed3e7f6b26cef82f11eb0b5f2476aef4249b63dad569eecfeb31618115606b204ce41fdb58b6b4187ef1521a2b89007321c
|
7
|
+
data.tar.gz: a1b75505baec7086b318b2d88f5bea5a2bb80aa0aec53373a065f545867e72b7f3551bde3a841cfc47941142474da932753b9343a95219655583cd21e5e70d31
|
data/lib/cellar.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# cellar - Ruby gem to deal with cells of data in rows and columns
|
3
3
|
#
|
4
4
|
# Author: Steve Shreeve (steve.shreeve@gmail.com)
|
5
|
-
# Date: October
|
5
|
+
# Date: October 9, 2024
|
6
6
|
#
|
7
7
|
# TODO:
|
8
8
|
# • Should we failover to empty strings like this: (value || "")
|
@@ -24,7 +24,7 @@ class Object
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Cellar
|
27
|
-
VERSION="0.1.
|
27
|
+
VERSION="0.1.5"
|
28
28
|
|
29
29
|
attr_reader :fields
|
30
30
|
attr_reader :values
|
@@ -62,6 +62,19 @@ class Cellar
|
|
62
62
|
index
|
63
63
|
end
|
64
64
|
|
65
|
+
def rename_field(field, other)
|
66
|
+
field = field.to_s
|
67
|
+
index = index(field) or raise "unable to rename the #{field.inspect} field"
|
68
|
+
@finder.delete(field.downcase.gsub(/\W/,'_'))
|
69
|
+
@finder.delete(field)
|
70
|
+
other = other.to_s
|
71
|
+
fields[index] = other
|
72
|
+
@finder[other.downcase.gsub(/\W/,'_')] ||= index
|
73
|
+
@finder[other] ||= index
|
74
|
+
@widest = fields.map(&:size).max
|
75
|
+
index
|
76
|
+
end
|
77
|
+
|
65
78
|
def index(field)
|
66
79
|
case field
|
67
80
|
when String, Symbol
|