active_object 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +77 -3
- data/lib/active_object/object.rb +37 -1
- data/lib/active_object/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 144b8b5e8084e1f969f3542194b89f4c44103940
|
4
|
+
data.tar.gz: 7add4107e7707f066907d3af8143c4de19038f25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0db718cac3d970dbda8359eaf85ded18d159a048683302249ddc6a94d550f68f700f066c87e2719cc6952941d382998f7ce80399e60e218d2a87da27eb4df670
|
7
|
+
data.tar.gz: fd8e1564855b9603afccc68b28c9afb6a5994bfa2647eb97edd46516cf2227398529ba72b692391620ecec9cc2bfa6b8aca626b5cc486d8784c3062bacd0606e
|
data/README.md
CHANGED
@@ -1107,6 +1107,14 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
1107
1107
|
|
1108
1108
|
## Object
|
1109
1109
|
|
1110
|
+
####Array:####
|
1111
|
+
`array?` determines if an object is an array.
|
1112
|
+
|
1113
|
+
```ruby
|
1114
|
+
[].array? #=> true
|
1115
|
+
"Awesome Sting".array? #=> false
|
1116
|
+
```
|
1117
|
+
|
1110
1118
|
####Blank:####
|
1111
1119
|
`blank?` determines if an object is empty or nil. `Rails Safe`
|
1112
1120
|
|
@@ -1115,6 +1123,15 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
1115
1123
|
"Awesome Sting".blank? #=> false
|
1116
1124
|
```
|
1117
1125
|
|
1126
|
+
####Boolean:####
|
1127
|
+
`boolean?` determines if an object is an boolean.
|
1128
|
+
|
1129
|
+
```ruby
|
1130
|
+
1.boolean? #=> true
|
1131
|
+
false.boolean? #=> true
|
1132
|
+
"foo".boolean? #=> false
|
1133
|
+
```
|
1134
|
+
|
1118
1135
|
####False:####
|
1119
1136
|
`false?` determines if an object is false.
|
1120
1137
|
|
@@ -1132,12 +1149,45 @@ true.falsey? #=> false
|
|
1132
1149
|
0.falsey? #=> true
|
1133
1150
|
```
|
1134
1151
|
|
1152
|
+
####Float:####
|
1153
|
+
`float?` determines if an object is a float.
|
1154
|
+
|
1155
|
+
```ruby
|
1156
|
+
1.0.float? #=> true
|
1157
|
+
1.float? #=> false
|
1158
|
+
```
|
1159
|
+
|
1160
|
+
####Hash:####
|
1161
|
+
`hash?` determines if an object is a hash.
|
1162
|
+
|
1163
|
+
```ruby
|
1164
|
+
{}.hash? #=> true
|
1165
|
+
[].hash? #=> false
|
1166
|
+
```
|
1167
|
+
|
1168
|
+
####Integer:####
|
1169
|
+
`integer?` determines if an object is a integer.
|
1170
|
+
|
1171
|
+
```ruby
|
1172
|
+
1.integer? #=> true
|
1173
|
+
1.0.integer? #=> false
|
1174
|
+
```
|
1175
|
+
|
1135
1176
|
####Numeric:####
|
1136
|
-
`numeric?` determines if an object
|
1177
|
+
`numeric?` determines if an object is numeric.
|
1178
|
+
|
1179
|
+
```ruby
|
1180
|
+
1.numeric? #=> true
|
1181
|
+
1.0.numeric? #=> true
|
1182
|
+
"1.0".numeric? #=> false
|
1183
|
+
```
|
1184
|
+
|
1185
|
+
####Numeral:####
|
1186
|
+
`numeral?` determines if an object's string value is numeral.
|
1137
1187
|
|
1138
1188
|
```ruby
|
1139
|
-
"-32.50".
|
1140
|
-
"$2.55".
|
1189
|
+
"-32.50".numeral? #=> true
|
1190
|
+
"$2.55".numeral? #=> false
|
1141
1191
|
```
|
1142
1192
|
|
1143
1193
|
####Palindrome:####
|
@@ -1158,6 +1208,14 @@ true.falsey? #=> false
|
|
1158
1208
|
"".present? #=> false
|
1159
1209
|
```
|
1160
1210
|
|
1211
|
+
####Range:####
|
1212
|
+
`range?` determines if an object is a range.
|
1213
|
+
|
1214
|
+
```ruby
|
1215
|
+
(1..2).range? #=> true
|
1216
|
+
1.range? #=> false
|
1217
|
+
```
|
1218
|
+
|
1161
1219
|
####Salvage:####
|
1162
1220
|
`salvage` returns a placeholder if object is blank?.
|
1163
1221
|
|
@@ -1167,6 +1225,22 @@ nil.salvage("bar") #=> "bar"
|
|
1167
1225
|
123.salvage #=> 123
|
1168
1226
|
```
|
1169
1227
|
|
1228
|
+
####String:####
|
1229
|
+
`string?` determines if an object is a string.
|
1230
|
+
|
1231
|
+
```ruby
|
1232
|
+
"foo".string? #=> true
|
1233
|
+
1.string? #=> false
|
1234
|
+
```
|
1235
|
+
|
1236
|
+
####Time:####
|
1237
|
+
`time?` determines if an object is a time.
|
1238
|
+
|
1239
|
+
```ruby
|
1240
|
+
Time.now.time? #=> true
|
1241
|
+
"foo".time? #=> false
|
1242
|
+
```
|
1243
|
+
|
1170
1244
|
####True:####
|
1171
1245
|
`true?` determines if an object is true.
|
1172
1246
|
|
data/lib/active_object/object.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
class Object
|
2
2
|
|
3
|
+
def array?
|
4
|
+
is_a?(Array)
|
5
|
+
end
|
6
|
+
|
3
7
|
unless defined?(Rails)
|
4
8
|
def blank?
|
5
9
|
object = self
|
@@ -8,6 +12,10 @@ class Object
|
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
15
|
+
def boolean?
|
16
|
+
[false, true, nil, 0, 1].include?(self)
|
17
|
+
end
|
18
|
+
|
11
19
|
def false?
|
12
20
|
self == false
|
13
21
|
end
|
@@ -16,10 +24,26 @@ class Object
|
|
16
24
|
[false, nil, 0].include?(self)
|
17
25
|
end
|
18
26
|
|
19
|
-
def
|
27
|
+
def float?
|
28
|
+
is_a?(Float)
|
29
|
+
end
|
30
|
+
|
31
|
+
def hash?
|
32
|
+
is_a?(Hash)
|
33
|
+
end
|
34
|
+
|
35
|
+
def integer?
|
36
|
+
is_a?(Integer)
|
37
|
+
end
|
38
|
+
|
39
|
+
def numeral?
|
20
40
|
!to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/).nil?
|
21
41
|
end
|
22
42
|
|
43
|
+
def numeric?
|
44
|
+
is_a?(Numeric)
|
45
|
+
end
|
46
|
+
|
23
47
|
def palindrome?
|
24
48
|
to_s == to_s.reverse
|
25
49
|
end
|
@@ -30,10 +54,22 @@ class Object
|
|
30
54
|
end
|
31
55
|
end
|
32
56
|
|
57
|
+
def range?
|
58
|
+
is_a?(Range)
|
59
|
+
end
|
60
|
+
|
33
61
|
def salvage(placeholder="---")
|
34
62
|
blank? ? placeholder : self
|
35
63
|
end
|
36
64
|
|
65
|
+
def string?
|
66
|
+
is_a?(String)
|
67
|
+
end
|
68
|
+
|
69
|
+
def time?
|
70
|
+
is_a?(Time)
|
71
|
+
end
|
72
|
+
|
37
73
|
def true?
|
38
74
|
self == true
|
39
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|