true_table 0.2.0 → 0.2.1

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/true_table.rb +38 -0
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53e26ebda846b40d7f2399e318b3be09ce49c71ddebbab97bfc34fbd64d664b4
4
- data.tar.gz: 1427d9de17b647d15469522ea5483b268ca41ef82a325b286617dc72ada93ad9
3
+ metadata.gz: 3373190811f6525585ae75db80f24ba653816005938d107734b653dd7a84d9cd
4
+ data.tar.gz: ced003b960d0be4b45a0272f3186d7d5fcd0161ffd609967850ca5d69289e424
5
5
  SHA512:
6
- metadata.gz: b2aa85ebfd3c93611bcd499fa1c551dfac70b552353e89e60e0a68362763c9e8e5663d9557d310d36fb488409aaf3fac46234dc95fe18644422fc7654ec05155
7
- data.tar.gz: 9c8d9423738e0724c3bbcac5fc93187c8bd8c2e68cd5cb8a481324bd0b2080b3087ff9dad498b024ec41f0784a061afc0988c5654f177073c2a1334ec9cb78e1
6
+ metadata.gz: 176bb664a7e4357c43fcad729ba7334599e461e8ed1579336078ff7704eafa1b038c2b3cd085559a89cc7147ba13a3ff8f1c853f498b333dbf03284e2d52e0bd
7
+ data.tar.gz: 61b623d2fd727b89c2e972fa859906f11f042474e77a933239a83354ea6f6175f2704317ea2cc6aca8d1f3f43f6843baeace9a7de84280c621fb16bd096e4306
@@ -115,6 +115,16 @@ class TrueTable < Array
115
115
  end
116
116
  end
117
117
 
118
+ # Returns a new table without the first N rows
119
+ def drop(*args)
120
+ self.class.new super
121
+ end
122
+
123
+ # Returns a new table with rows until the block returns false
124
+ def drop_while(*args)
125
+ self.class.new super
126
+ end
127
+
118
128
  # Iterates over columns
119
129
  def each_col
120
130
  headers.each { |header| yield col(header), header }
@@ -198,6 +208,24 @@ class TrueTable < Array
198
208
  self.class.new super
199
209
  end
200
210
 
211
+ # Returns a new table slice
212
+ def slice(*args)
213
+ if args.count == 1 and args.first.is_a? Integer
214
+ super
215
+ else
216
+ self.class.new super
217
+ end
218
+ end
219
+
220
+ # Deletes and returns one more rows
221
+ def slice!(*args)
222
+ if args.count == 1 and args.first.is_a? Integer
223
+ super
224
+ else
225
+ self.class.new super
226
+ end
227
+ end
228
+
201
229
  # Returns a new sorted table
202
230
  def sort
203
231
  self.class.new super
@@ -208,6 +236,16 @@ class TrueTable < Array
208
236
  self.class.new super
209
237
  end
210
238
 
239
+ # Returns a new table with the first N rows
240
+ def take(*args)
241
+ self.class.new super
242
+ end
243
+
244
+ # Returns a new table with rows until the block returns false
245
+ def take_while(*args)
246
+ self.class.new super
247
+ end
248
+
211
249
  # Returns a CSV string
212
250
  def to_csv(row_separator = "\n", col_separator = ",")
213
251
  join(row_separator, col_separator, with_headers: true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: true_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-09 00:00:00.000000000 Z
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simple and intuitive tabular data type
14
14
  email: db@dannyben.com
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
37
  - !ruby/object:Gem::Version
38
38
  version: '0'
39
39
  requirements: []
40
- rubygems_version: 3.1.2
40
+ rubygems_version: 3.2.3
41
41
  signing_key:
42
42
  specification_version: 4
43
43
  summary: Simple and intuitive tabular data type