lite-ruby 1.0.31 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15a0127d8b5abef7b86a8b357d76bd81721b3e17633e25935d074c914f2ce6c9
4
- data.tar.gz: 0e0cbbb3cb414574370770851e3423b1f09094d1aebd0a133897c24ad9b40588
3
+ metadata.gz: 4095b0d8f2c311166ae6e3c707ba2437517bf6556440ed5613fc0d931be7acb2
4
+ data.tar.gz: 574f86f3a826e1af9a34787341712c425309214b54842f5b3087c0057bcd9dde
5
5
  SHA512:
6
- metadata.gz: 28cb3f81b2df9ff0483153c8c7077c04220efa0012958d6533cd8903a6d7b22e1099ab77c5c3db6b024cf04d211c37eb8bae9581e6457c02ddf1d891a5bf7142
7
- data.tar.gz: 5adfc54f1824eab97ab7f23f20ea4b33f3405fddbd97ba32d48fa93f883eb35e0f6f9d70ac24f39ff046ae5a0775a080e0fcffaea1cfd4ce3e353e50afcd1bf8
6
+ metadata.gz: df9078ba4edcac6279821fe3adf58f47f78f0ade91ba9359b805599eda8fb8b532ea242d92c2b0960e3e49674179e7153a87286bc3ba4a5d27c231432c035ec9
7
+ data.tar.gz: 1b183bb09263ccc731626cbfbee11f05e39a32caf00ec3cc2ce4f7297052f929b6899c7a3adc3d80cd573a546d6be986898cc64cce9f1848b8ae6a2d70d801d5
@@ -44,6 +44,8 @@ RSpec/ExampleLength:
44
44
  Enabled: false
45
45
  RSpec/MultipleExpectations:
46
46
  Enabled: false
47
+ Style/ArgumentsForwarding:
48
+ Enabled: false
47
49
  Style/Documentation:
48
50
  Enabled: false
49
51
  Style/ExpandPathArguments:
@@ -6,6 +6,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.1.4] - 2020-11-19
10
+ ### Changed
11
+ - Object `array?` coerce ARGV check from nil to string
12
+
13
+ ## [1.1.3] - 2020-11-18
14
+ ### Changed
15
+ - Object `array?` does not clash with PG gem
16
+
17
+ ## [1.1.2] - 2020-11-08
18
+ ### Changed
19
+ - Array `extract!` does not alias except
20
+ - Update string methods to mutate self
21
+
22
+ ## [1.1.1] - 2020-11-08
23
+ ### Changed
24
+ - Revert String => `transliterize` to `transliterate`
25
+
26
+ ## [1.1.0] - 2020-11-06
27
+ ### Added
28
+ - Added Array => `extract!` to `except!` alias
29
+ - Added Array => `only(!)` to `select_values(!)` alias
30
+ - Added Hash => `collect_keys` to `map_keys` alias
31
+ - Added Hash => `collect_values` to `map_values` alias
32
+ ### Changed
33
+ - Rename Date, Time => `[method_name]_12` to `[method_name]12` ex: `hour_12` is now `hour12`
34
+ - Rename String => `transliterize` to `transliterate`
35
+ - Skip loading clashing methods with active support
36
+ ### Remove
37
+ - Numeric `clamp`
38
+
9
39
  ## [1.0.31] - 2020-09-21
10
40
  ### Changed
11
41
  - Changed `block_given?` => `defined?(yield)` for more performance
@@ -26,8 +56,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
26
56
 
27
57
  ## [1.0.26] - 2020-06-12
28
58
  ### Added
29
- - Added array => `all_after`
30
- - Added array => `all_before`
59
+ - Added Array => `all_after`
60
+ - Added Array => `all_before`
31
61
 
32
62
  ## [1.0.26] - 2020-05-22
33
63
  ### Changed
@@ -1,25 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-ruby (1.0.31)
4
+ lite-ruby (1.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actionpack (6.0.3.3)
10
- actionview (= 6.0.3.3)
11
- activesupport (= 6.0.3.3)
9
+ actionpack (6.0.3.4)
10
+ actionview (= 6.0.3.4)
11
+ activesupport (= 6.0.3.4)
12
12
  rack (~> 2.0, >= 2.0.8)
13
13
  rack-test (>= 0.6.3)
14
14
  rails-dom-testing (~> 2.0)
15
15
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
16
- actionview (6.0.3.3)
17
- activesupport (= 6.0.3.3)
16
+ actionview (6.0.3.4)
17
+ activesupport (= 6.0.3.4)
18
18
  builder (~> 3.1)
19
19
  erubi (~> 1.4)
20
20
  rails-dom-testing (~> 2.0)
21
21
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
22
- activesupport (6.0.3.3)
22
+ activesupport (6.0.3.4)
23
23
  concurrent-ruby (~> 1.0, >= 1.0.2)
24
24
  i18n (>= 0.7, < 2)
25
25
  minitest (~> 5.1)
@@ -31,7 +31,7 @@ GEM
31
31
  concurrent-ruby (1.1.7)
32
32
  crass (1.0.6)
33
33
  diff-lcs (1.4.4)
34
- erubi (1.9.0)
34
+ erubi (1.10.0)
35
35
  fasterer (0.8.3)
36
36
  colorize (~> 0.7)
37
37
  ruby_parser (>= 3.14.1)
@@ -48,8 +48,8 @@ GEM
48
48
  minitest (5.14.2)
49
49
  nokogiri (1.10.10)
50
50
  mini_portile2 (~> 2.4.0)
51
- parallel (1.19.2)
52
- parser (2.7.1.4)
51
+ parallel (1.20.0)
52
+ parser (2.7.2.0)
53
53
  ast (~> 2.4.1)
54
54
  rack (2.2.3)
55
55
  rack-test (1.1.0)
@@ -59,55 +59,56 @@ GEM
59
59
  nokogiri (>= 1.6)
60
60
  rails-html-sanitizer (1.3.0)
61
61
  loofah (~> 2.3)
62
- railties (6.0.3.3)
63
- actionpack (= 6.0.3.3)
64
- activesupport (= 6.0.3.3)
62
+ railties (6.0.3.4)
63
+ actionpack (= 6.0.3.4)
64
+ activesupport (= 6.0.3.4)
65
65
  method_source
66
66
  rake (>= 0.8.7)
67
67
  thor (>= 0.20.3, < 2.0)
68
68
  rainbow (3.0.0)
69
69
  rake (13.0.1)
70
- regexp_parser (1.8.0)
70
+ regexp_parser (1.8.2)
71
71
  rexml (3.2.4)
72
- rspec (3.9.0)
73
- rspec-core (~> 3.9.0)
74
- rspec-expectations (~> 3.9.0)
75
- rspec-mocks (~> 3.9.0)
76
- rspec-core (3.9.2)
77
- rspec-support (~> 3.9.3)
78
- rspec-expectations (3.9.2)
72
+ rspec (3.10.0)
73
+ rspec-core (~> 3.10.0)
74
+ rspec-expectations (~> 3.10.0)
75
+ rspec-mocks (~> 3.10.0)
76
+ rspec-core (3.10.0)
77
+ rspec-support (~> 3.10.0)
78
+ rspec-expectations (3.10.0)
79
79
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.9.0)
81
- rspec-mocks (3.9.1)
80
+ rspec-support (~> 3.10.0)
81
+ rspec-mocks (3.10.0)
82
82
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.9.0)
84
- rspec-support (3.9.3)
85
- rubocop (0.91.0)
83
+ rspec-support (~> 3.10.0)
84
+ rspec-support (3.10.0)
85
+ rubocop (1.3.1)
86
86
  parallel (~> 1.10)
87
- parser (>= 2.7.1.1)
87
+ parser (>= 2.7.1.5)
88
88
  rainbow (>= 2.2.2, < 4.0)
89
- regexp_parser (>= 1.7)
89
+ regexp_parser (>= 1.8)
90
90
  rexml
91
- rubocop-ast (>= 0.4.0, < 1.0)
91
+ rubocop-ast (>= 1.1.1)
92
92
  ruby-progressbar (~> 1.7)
93
93
  unicode-display_width (>= 1.4.0, < 2.0)
94
- rubocop-ast (0.4.2)
95
- parser (>= 2.7.1.4)
96
- rubocop-performance (1.8.1)
97
- rubocop (>= 0.87.0)
94
+ rubocop-ast (1.1.1)
95
+ parser (>= 2.7.1.5)
96
+ rubocop-performance (1.9.0)
97
+ rubocop (>= 0.90.0, < 2.0)
98
98
  rubocop-ast (>= 0.4.0)
99
- rubocop-rspec (1.43.2)
100
- rubocop (~> 0.87)
99
+ rubocop-rspec (2.0.0)
100
+ rubocop (~> 1.0)
101
+ rubocop-ast (>= 1.1.0)
101
102
  ruby-progressbar (1.10.1)
102
103
  ruby_parser (3.15.0)
103
104
  sexp_processor (~> 4.9)
104
105
  sexp_processor (4.15.1)
105
106
  thor (1.0.1)
106
107
  thread_safe (0.3.6)
107
- tzinfo (1.2.7)
108
+ tzinfo (1.2.8)
108
109
  thread_safe (~> 0.1)
109
110
  unicode-display_width (1.7.0)
110
- zeitwerk (2.4.0)
111
+ zeitwerk (2.4.1)
111
112
 
112
113
  PLATFORMS
113
114
  ruby
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Build Status](https://travis-ci.org/drexed/lite-ruby.svg?branch=master)](https://travis-ci.org/drexed/lite-ruby)
5
5
 
6
6
  Lite::Ruby is a collection of useful Ruby methods for its primitive classes.
7
+ AcitveSupport equivalent methods do not get included when AcitveSupport is available.
7
8
 
8
9
  **NOTE:** If you are coming from `ActiveObject`, please read the [port](#port) section.
9
10
 
@@ -155,7 +155,7 @@ Returns a list of duplicate elements.
155
155
  [1, 1, 2, 2, 2, 3].duplicates(3) #=> [2]
156
156
  ```
157
157
 
158
- `except(!)`
158
+ `except(!)` aka `remove_values(!)`
159
159
  ------
160
160
  Removes given values from the array.
161
161
 
@@ -163,6 +163,16 @@ Removes given values from the array.
163
163
  [1, 2, 3, 4].except(1, 3) #=> [2, 4]
164
164
  ```
165
165
 
166
+ `extract!`
167
+ ------
168
+ Removes and returns the elements for which the block returns a true value. If no block is given, an Enumerator is returned instead.
169
+
170
+ ```ruby
171
+ a1 = [1, 2, 3, 4]
172
+ a1.extract!(&:odd?) #=> [1, 3]
173
+ a1 #=> [2, 4]
174
+ ```
175
+
166
176
  `from`
167
177
  ------
168
178
  Returns the tail of the array from a given position.
@@ -235,7 +245,7 @@ Converts blank values into `nil`.
235
245
  ['', 3, 4].nillify! #=> [nil, 3, 4]
236
246
  ```
237
247
 
238
- `only(!)`
248
+ `only(!)` aka `select_values(!)`
239
249
  ------
240
250
  Selects given values from the array.
241
251
 
@@ -285,14 +295,6 @@ Returns a sample of random n values by size or given.
285
295
  [1, 2, 3].rand_sample(1) #=> [2]
286
296
  ```
287
297
 
288
- `reject_values`
289
- ------
290
- Delete multiple values from a `dup` copy of the original array.
291
-
292
- ```ruby
293
- [1, 2, 3, 4, 5].reject_values(2, 4) #=> [1, 3, 5]
294
- ```
295
-
296
298
  `rposition`
297
299
  ------
298
300
  Returns the position of the last matching value.
@@ -110,7 +110,7 @@ Merge the values of this hash with those from another, setting all values to be
110
110
  { a: 1, b: 2 }.collate(a: 3, b: 4, c: 5) #=> { a: [1, 3], b: [2, 4], c: [5] }
111
111
  ```
112
112
 
113
- `collect_keys`
113
+ `collect_keys` aka `map_keys`
114
114
  ------
115
115
  Returns an array with all keys converted using the block operation.
116
116
 
@@ -119,7 +119,7 @@ Returns an array with all keys converted using the block operation.
119
119
  { foo: 'bar', 'baz' => :boo }.collect_keys { |k| k.to_s.upcase } #=> ['FOO', BAZ']
120
120
  ```
121
121
 
122
- `collect_values`
122
+ `collect_values` aka `map_values`
123
123
  ------
124
124
  Returns an array with all values converted using the block operation.
125
125
 
@@ -8,16 +8,6 @@ Returns the sum of two numbers.
8
8
  4.add(2) #=> 6
9
9
  ```
10
10
 
11
- `clamp`
12
- ------
13
- Returns the closest number outside of the lower and upper bound.
14
-
15
- ```ruby
16
- 1.clamp(3, 6) # => 3
17
- 5.clamp(3..6) # => 5
18
- 8.clamp(3, 6) # => 6
19
- ```
20
-
21
11
  `close?`
22
12
  ------
23
13
  Returns if a number is within the degree of another.
@@ -20,8 +20,8 @@ Converts a `time` object to `strftime` it using a human readable string.
20
20
  | --- | --- | --- | --- | --- |
21
21
  | Hour | 24h zero-padded | `h`, `hour`, `hour_padded` | %H | (00..23) |
22
22
  | Hour | 24h blank-padded | `hh`, `HOUR`, `hour_blank` | %k | ( 0..23) |
23
- | Hour | 12h zero-padded | `hhh`, `hour_12`, `hour_12_padded` | %I | (01..12) |
24
- | Hour | 12h blank-padded | `hhhh`, `HOUR_12`, `hour_12_blank` | %l | ( 1..12) |
23
+ | Hour | 12h zero-padded | `hhh`, `hour12`, `hour12_padded` | %I | (01..12) |
24
+ | Hour | 12h blank-padded | `hhhh`, `HOUR12`, `hour12_blank` | %l | ( 1..12) |
25
25
  | Minute | Minute | `n`, `minute` | %M | (00..59) |
26
26
  | Second | Second | `s`, `second` | %S | (00..59) |
27
27
  | Meridian | Lowercase | `ampm`, `meridian` | %P | am..pm |
@@ -48,8 +48,8 @@ Converts a `time` object to a predefined format.
48
48
  | --- | --- | --- | --- | --- |
49
49
  | Hour | 24h zero-padded | `:hour`, `:hour_padded` | %H | (00..23) |
50
50
  | Hour | 24h blank-padded | `:hour_blank` | %k | ( 0..23) |
51
- | Hour | 12h zero-padded | `hour_12`, `:hour_12_padded` | %I | (01..12) |
52
- | Hour | 12h blank-padded | `:hour_12_blank` | %l | ( 1..12) |
51
+ | Hour | 12h zero-padded | `hour12`, `:hour12_padded` | %I | (01..12) |
52
+ | Hour | 12h blank-padded | `:hour12_blank` | %l | ( 1..12) |
53
53
  | Minute | Minute | `:minute` | %M | (00..59) |
54
54
  | Second | Second | `:second` | %S | (00..59) |
55
55
  | Meridian | Lowercase | `:ampm` | %P | am..pm |
@@ -67,28 +67,28 @@ Converts a `time` object to a predefined format.
67
67
  | Combo | 24h time | `:time_blank` | %k:%M %z | 0:31 |
68
68
  | Combo | 24h time | `:time_tz` | %H:%M %z | 00:31 +0000 |
69
69
  | Combo | 24h time | `:time_tzn` | %H:%M %Z | 00:31 UTC |
70
- | Combo | 12h time | `:time_12`, `:time_12_padded` | %I:%M %P | 07:31 am |
71
- | Combo | 12h time | `:time_12_blank` | %l:%M %P | 7:31 am |
72
- | Combo | 12h Time | `:time_12_tz` | %I:%M %P %z | 07:31 am +0000 |
73
- | Combo | 12h Time | `:time_12_tzn` | %I:%M %P %Z | 07:31 am UTC |
70
+ | Combo | 12h time | `:time12`, `:time12_padded` | %I:%M %P | 07:31 am |
71
+ | Combo | 12h time | `:time12_blank` | %l:%M %P | 7:31 am |
72
+ | Combo | 12h Time | `:time12_tz` | %I:%M %P %z | 07:31 am +0000 |
73
+ | Combo | 12h Time | `:time12_tzn` | %I:%M %P %Z | 07:31 am UTC |
74
74
  | Combo | 24h daytime | `:daytime` | %B %-d %H:%M | January 9 00:31 |
75
75
  | Combo | 24h daytime | `:daytime_abbr` | %b %-d %H:%M | Jan 9 00:31 |
76
76
  | Combo | 24h daytime | `:daytime_iso` | %m-%d %H:%M | 01-09 00:31 |
77
- | Combo | 12h daytime | `:daytime_12` | %B %-d %H:%M | January 9 12:31 am |
78
- | Combo | 12h daytime | `:daytime_12_abbr` | %b %-d %H:%M | Jan 9 12:31 am |
79
- | Combo | 12h daytime | `:daytime_12_iso` | %m-%d %H:%M | 01-09 12:31 am |
77
+ | Combo | 12h daytime | `:daytime12` | %B %-d %H:%M | January 9 12:31 am |
78
+ | Combo | 12h daytime | `:daytime12_abbr` | %b %-d %H:%M | Jan 9 12:31 am |
79
+ | Combo | 12h daytime | `:daytime12_iso` | %m-%d %H:%M | 01-09 12:31 am |
80
80
  | Combo | 24h datetime | `:datetime` | %B %-d, %Y %H:%M | January 9, 2014 00:31 |
81
81
  | Combo | 24h datetime | `:datetime_abbr` | %b %-d, %Y %H:%M | Jan 9, 2014 00:31 |
82
82
  | Combo | 24h datetime | `:datetime_iso` | %Y-%m-%d %H:%M | 2014-01-09 00:31 |
83
83
  | Combo | 24h datetime | `:datetime_tzn` | %B %-d, %Y %H:%M %Z | January 9, 2014 00:31 UTC |
84
84
  | Combo | 24h datetime | `:datetime_abbr_tzn` | %b %-d, %Y %H:%M %Z | Jan 9, 2014 00:31 UTC |
85
85
  | Combo | 24h datetime | `:datetime_iso_tzn` | %Y-%m-%d %H:%M %z | 2014-01-09 00:31 +0000 |
86
- | Combo | 12h datetime | `:datetime_12` | %B %-d, %Y %H:%M | January 9, 2014 12:31 am |
87
- | Combo | 12h datetime | `:datetime_12_abbr` | %b %-d, %Y %H:%M | Jan 9, 2014 12:31 am |
88
- | Combo | 12h datetime | `:datetime_12_iso` | %Y-%m-%d %H:%M | 2014-01-09 12:31 am |
89
- | Combo | 12h datetime | `:datetime_12_tzn` | %B %-d, %Y %H:%M %Z | January 9, 2014 12:31 am UTC |
90
- | Combo | 12h datetime | `:datetime_12_abbr_tzn` | %b %-d, %Y %H:%M %Z | Jan 9, 2014 12:31 am UTC |
91
- | Combo | 12h datetime | `:datetime_12_iso_tzn` | %Y-%m-%d %H:%M %z | 2014-01-09 12:31 am +0000 |
86
+ | Combo | 12h datetime | `:datetime12` | %B %-d, %Y %H:%M | January 9, 2014 12:31 am |
87
+ | Combo | 12h datetime | `:datetime12_abbr` | %b %-d, %Y %H:%M | Jan 9, 2014 12:31 am |
88
+ | Combo | 12h datetime | `:datetime12_iso` | %Y-%m-%d %H:%M | 2014-01-09 12:31 am |
89
+ | Combo | 12h datetime | `:datetime12_tzn` | %B %-d, %Y %H:%M %Z | January 9, 2014 12:31 am UTC |
90
+ | Combo | 12h datetime | `:datetime12_abbr_tzn` | %b %-d, %Y %H:%M %Z | Jan 9, 2014 12:31 am UTC |
91
+ | Combo | 12h datetime | `:datetime12_iso_tzn` | %Y-%m-%d %H:%M %z | 2014-01-09 12:31 am +0000 |
92
92
 
93
93
  ```ruby
94
94
  Time.now.stamp(:datetime) #=> 'January 09, 2014 02:31 pm'
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  if Lite::Ruby.configuration.monkey_patches.include?('array')
4
+ require 'lite/ruby/safe/array' unless defined?(ActiveSupport)
5
+
4
6
  class Array
5
7
 
6
8
  def assert_min_values!(*valid_values)
@@ -109,10 +111,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
109
111
  # rubocop:enable Metrics/PerceivedComplexity, Style/GuardClause, Style/IfInsideElse
110
112
  # rubocop:enable Metrics/AbcSize, Metrics/BlockNesting, Metrics/MethodLength
111
113
 
112
- def deep_dup
113
- map(&:deep_dup)
114
- end
115
-
116
114
  def delete_first
117
115
  self[1..-1]
118
116
  end
@@ -160,11 +158,8 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
160
158
  end
161
159
 
162
160
  def except!(*values)
163
- replace(except(*values))
164
- end
165
-
166
- def from(position)
167
- self[position, size] || []
161
+ reject! { |val| values.include?(val) }
162
+ self
168
163
  end
169
164
 
170
165
  def fulfill(value, amount)
@@ -183,54 +178,12 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
183
178
  collection << self[-rem, rem]
184
179
  end
185
180
 
186
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
187
- def in_groups(number, fill_with = nil, &block)
188
- collection_size = size
189
- division = collection_size.div(number)
190
- modulo = collection_size % number
191
-
192
- collection = []
193
- start = 0
194
- number.times do |int|
195
- mod_gt_zero = modulo.positive?
196
- grouping = division + (mod_gt_zero && modulo > int ? 1 : 0)
197
- collection << last_group = slice(start, grouping)
198
- last_group << fill_with if (fill_with != false) && mod_gt_zero && (grouping == division)
199
- start += grouping
200
- end
201
-
202
- return collection unless defined?(yield)
203
-
204
- collection.each(&block)
205
- end
206
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
207
-
208
- # rubocop:disable Metrics/MethodLength, Style/GuardClause
209
- def in_groups_of(number, fill_with = nil, &block)
210
- if number.to_i <= 0
211
- raise ArgumentError, "Group size must be a positive integer, was #{number.inspect}"
212
- elsif fill_with == false
213
- collection = self
214
- else
215
- padding = (number - size % number) % number
216
- collection = dup.concat(Array.new(padding, fill_with))
217
- end
218
-
219
- sliced_collection = collection.each_slice(number)
220
- return sliced_collection.to_a unless defined?(yield)
221
-
222
- sliced_collection(&block)
223
- end
224
- # rubocop:enable Metrics/MethodLength, Style/GuardClause
225
-
226
181
  def indexes(value)
227
182
  array = []
228
183
  each_with_index { |val, i| array << i if value == val }
229
184
  array
230
185
  end
231
186
 
232
- alias indices indexes
233
-
234
187
  def merge(*values)
235
188
  dup.merge!(*values)
236
189
  end
@@ -252,7 +205,8 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
252
205
  end
253
206
 
254
207
  def only!(*values)
255
- replace(only(*values))
208
+ select! { |val| values.include?(val) }
209
+ self
256
210
  end
257
211
 
258
212
  def position(value)
@@ -284,7 +238,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
284
238
  end
285
239
 
286
240
  def promote!(value)
287
- replace(promote(value))
241
+ sort_by! { |val| val == value ? -1 : 0 }
288
242
  end
289
243
 
290
244
  def rand_sample(max = nil)
@@ -292,10 +246,6 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
292
246
  sample(amount)
293
247
  end
294
248
 
295
- def reject_values(*args)
296
- reject { |val| args.include?(val) }
297
- end
298
-
299
249
  def rposition(value)
300
250
  idx = rindex(value)
301
251
  return idx if idx.nil?
@@ -307,36 +257,13 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
307
257
  delete_at(Random.rand(size - 1))
308
258
  end
309
259
 
310
- # rubocop:disable Metrics/AbcSize, Metrics/BlockNesting, Metrics/MethodLength
311
- def split(number = nil)
312
- array = [[]]
313
-
314
- if defined?(yield)
315
- each { |val| yield(val) ? (array << []) : (array.last << val) }
316
- else
317
- dup_arr = dup
318
-
319
- until dup_arr.empty?
320
- if (idx = dup_arr.index(number))
321
- array.last << dup_arr.shift(idx)
322
- dup_arr.shift
323
- array << []
324
- else
325
- array.last << arr.shift(dup_arr.size)
326
- end
327
- end
328
- end
329
-
330
- array
331
- end
332
- # rubocop:enable Metrics/AbcSize, Metrics/BlockNesting, Metrics/MethodLength
333
-
334
260
  def strip
335
261
  reject(&:blank?)
336
262
  end
337
263
 
338
264
  def strip!
339
- replace(strip)
265
+ reject!(&:blank?)
266
+ self
340
267
  end
341
268
 
342
269
  def swap(from, to)
@@ -344,24 +271,11 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
344
271
  self
345
272
  end
346
273
 
347
- def to(position)
348
- return first(position + 1) if position >= 0
349
-
350
- self[0..position]
351
- end
352
-
353
- def to_sentence(options = {})
354
- words_connector = options[:words_connector] || ', '
355
- two_words_connector = options[:two_words_connector] || ' and '
356
- last_word_connector = options[:last_word_connector] || ', and '
357
-
358
- case size
359
- when 0 then ''
360
- when 1 then self[0].to_s.dup
361
- when 2 then "#{self[0]}#{two_words_connector}#{self[1]}"
362
- else "#{self[0...-1].join(words_connector)}#{last_word_connector}#{self[-1]}"
363
- end
364
- end
274
+ alias indices indexes
275
+ alias reject_values except
276
+ alias reject_values! except!
277
+ alias select_values only
278
+ alias select_values! only!
365
279
 
366
280
  end
367
281
  end