active_object 1.2.0 → 1.2.1
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 +4 -4
- data/README.md +5 -5
- data/lib/active_object/array.rb +12 -0
- data/lib/active_object/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c37d1b84c04412c27d1b8095b13e792d274c241f
|
4
|
+
data.tar.gz: c0af04da07d27d2563a57397636af1cb9dde3199
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0907a1844303d9f7671bffe5c9dbe7560147bdbfb2f52a15adf58610a284802de9de369155759c008447efe3a406a8ce939485b2fae70e130e02f8d7990f778
|
7
|
+
data.tar.gz: b80a219326e6fb02784ceb0e1a4b9a5c087772fc010c59c2431d9abd0ef62638fe11bc64598be9ff6a304b5dd5e918d7b7ff0d985dc3b6cab4376a7e710bd629
|
data/README.md
CHANGED
@@ -33,14 +33,14 @@ Or install it yourself as:
|
|
33
33
|
### Array
|
34
34
|
|
35
35
|
####Delete First:####
|
36
|
-
`delete_first` removes the first element from an array. Like Array.shift, but returns the array instead of the removed element.
|
36
|
+
`delete_first` and `delete_first!` removes the first element from an array. Like Array.shift, but returns the array instead of the removed element.
|
37
37
|
|
38
38
|
```ruby
|
39
39
|
["1", "2", "3"].delete_first #=> ["2", "3"]
|
40
40
|
```
|
41
41
|
|
42
42
|
####Delete Last:####
|
43
|
-
`delete_last` removes the last element from an array. Like Array.pop, but returns the array instead of the removed element.
|
43
|
+
`delete_last` and `delete_last!` removes the last element from an array. Like Array.pop, but returns the array instead of the removed element.
|
44
44
|
|
45
45
|
```ruby
|
46
46
|
["1", "2", "3"].delete_last #=> ["1", "2"]
|
@@ -89,7 +89,7 @@ Or install it yourself as:
|
|
89
89
|
```
|
90
90
|
|
91
91
|
####Strip:####
|
92
|
-
`strip` removes blank elements from an array.
|
92
|
+
`strip` and `strip!` removes blank elements from an array.
|
93
93
|
|
94
94
|
```ruby
|
95
95
|
["this", "", "that", nil, false].strip #=> ["this", "that"]
|
@@ -970,8 +970,8 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
970
970
|
`present?` determines if an object is not empty or nil. `Rails Safe`
|
971
971
|
|
972
972
|
```ruby
|
973
|
-
"Awesome Sting".
|
974
|
-
"".present?
|
973
|
+
"Awesome Sting".present? #=> true
|
974
|
+
"".present? #=> false
|
975
975
|
```
|
976
976
|
|
977
977
|
####Try:####
|
data/lib/active_object/array.rb
CHANGED
@@ -4,10 +4,18 @@ class Array
|
|
4
4
|
self[1..-1]
|
5
5
|
end
|
6
6
|
|
7
|
+
def delete_first!
|
8
|
+
replace(delete_first)
|
9
|
+
end
|
10
|
+
|
7
11
|
def delete_last
|
8
12
|
self[0...-1]
|
9
13
|
end
|
10
14
|
|
15
|
+
def delete_last!
|
16
|
+
replace(delete_last)
|
17
|
+
end
|
18
|
+
|
11
19
|
unless defined?(Rails)
|
12
20
|
def from(position)
|
13
21
|
self[position, size] || []
|
@@ -85,6 +93,10 @@ class Array
|
|
85
93
|
reject { |v| v.blank? }
|
86
94
|
end
|
87
95
|
|
96
|
+
def strip!
|
97
|
+
replace(strip)
|
98
|
+
end
|
99
|
+
|
88
100
|
unless defined?(Rails)
|
89
101
|
def to(position)
|
90
102
|
position >= 0 ? first(position + 1) : self[0..position]
|