rudash 2.11.1 → 2.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rudash/take.rb +14 -0
  3. data/lib/rudash.rb +2 -0
  4. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e03793015e21b55c2270f9a8dc164f2fda34cd245ed6321f7eee371d9999c0be
4
- data.tar.gz: 6de12ecd7cbe84c7a21be38b795ad4bac59cf2f3c54a3c820bba0bee7bb2053e
3
+ metadata.gz: c38108728a63feadae53822d148556bb36baf9b878b31e96e5d0f001f7f8b5d2
4
+ data.tar.gz: 2aaa7cf2e3524c154c451843023f95f0c3662f6175baeb264f906881039b5d01
5
5
  SHA512:
6
- metadata.gz: d5cdec12078e9ba71a407ffc0ddaca44fe887966cf54b23b6574ec46e28afe2a0120d73b5ca4dfbf0aef9b2a666e5a5b363711a21fc963a38f9bce9a4b2de61d
7
- data.tar.gz: c3116e82e35c91691b61bfde79c3611c398f996fde5ad6ef0fc0c33be1012d26f00c6d784a7ab6187b17f119f5fe5ff24f5c07af06c8465c60673e73a3fab3ed
6
+ metadata.gz: ae6c39b3aa21a337f9ad64a6e1414656c054c12f09ec26934c3470fb4ee6753d357be859a28b740839c58b8718cd1f82048c9798a920cd5b80689d023218e2cc
7
+ data.tar.gz: 322e18ecec3658ece61340ddd2433314df9205a31af5c7eae76964e01508e9790c41f0832982af2b2d50114f2848929ddf1a75b290daa232c10917fb30ae6e79
@@ -0,0 +1,14 @@
1
+ module Rudash
2
+ module Take
3
+ def take(array, *rest_args)
4
+ return [] if !self.is_array?(array)
5
+ count = self.head(rest_args) || 1
6
+
7
+ begin
8
+ return array.take(count)
9
+ rescue
10
+ return []
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/rudash.rb CHANGED
@@ -46,6 +46,7 @@ require_relative './rudash/union.rb'
46
46
  require_relative './rudash/reject.rb'
47
47
  require_relative './rudash/range.rb'
48
48
  require_relative './rudash/group_by.rb'
49
+ require_relative './rudash/take.rb'
49
50
 
50
51
  # This is the exposed Gem class that contains all Rudash methods.
51
52
  # New methods can use already implemented methods in the library by refering to "self"
@@ -99,4 +100,5 @@ class R_
99
100
  extend Rudash::Reject
100
101
  extend Rudash::Range
101
102
  extend Rudash::GroupBy
103
+ extend Rudash::Take
102
104
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudash
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.1
4
+ version: 2.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Islam Attrash
@@ -61,6 +61,7 @@ files:
61
61
  - lib/rudash/slice.rb
62
62
  - lib/rudash/some.rb
63
63
  - lib/rudash/tail.rb
64
+ - lib/rudash/take.rb
64
65
  - lib/rudash/union.rb
65
66
  - lib/rudash/uniq.rb
66
67
  - lib/rudash/update.rb