cellar 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cellar.rb +17 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f45811a66c7c570a6b09c891dc7e4ebde205485312fd40444d6060470ed6249f
4
- data.tar.gz: 3f752cc5cb1ea78184616eb30bf1fd141a9d2f362fcd6bd971948faf43af3288
3
+ metadata.gz: be9c519146063e4b17e8736dfd6d58f968411ef172c2c7ba4bb6f9f2669f7ebc
4
+ data.tar.gz: a030af0aaa876017a8ec86960aff3fb3f10d0265b8750b6a7f2fb8e14260f5ce
5
5
  SHA512:
6
- metadata.gz: 23939a9a8e1e7cf5be52c494389b9372e0ea1e9a7602a0e9ebc17a9980162cc0f2d739e7712235ab0b5bc6572f021a38004ffe2c157e5c53e0bac09ba2b586ce
7
- data.tar.gz: da5f109fa8b7558602d7fdc4d58355aef5c926881f5532e529f01345475fdb56badf3b2943b97da973f0f707928c9512b0a1ea031ab9a72e66de9dbe1d2b819d
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 8, 2024
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.3"
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
@@ -98,6 +111,8 @@ class Cellar
98
111
  when 0
99
112
  []
100
113
  when 1
114
+ first = fields.first
115
+ first.is_a?(Cellar) and return self[*first.fields]
101
116
  index = index(fields.first)
102
117
  value = @values[index] if index
103
118
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cellar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-09 00:00:00.000000000 Z
11
+ date: 2024-10-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby gem to deal with cells of data in rows and columns
14
14
  email: steve.shreeve@gmail.com