|
Revision 9226, 0.7 kB
(checked in by pratik, 1 year ago)
|
Improve documentation.
|
| Line | |
|---|
| 1 |
class Object |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
def blank? |
|---|
| 13 |
respond_to?(:empty?) ? empty? : !self |
|---|
| 14 |
end |
|---|
| 15 |
end |
|---|
| 16 |
|
|---|
| 17 |
class NilClass |
|---|
| 18 |
def blank? |
|---|
| 19 |
true |
|---|
| 20 |
end |
|---|
| 21 |
end |
|---|
| 22 |
|
|---|
| 23 |
class FalseClass |
|---|
| 24 |
def blank? |
|---|
| 25 |
true |
|---|
| 26 |
end |
|---|
| 27 |
end |
|---|
| 28 |
|
|---|
| 29 |
class TrueClass |
|---|
| 30 |
def blank? |
|---|
| 31 |
false |
|---|
| 32 |
end |
|---|
| 33 |
end |
|---|
| 34 |
|
|---|
| 35 |
class Array |
|---|
| 36 |
alias_method :blank?, :empty? |
|---|
| 37 |
end |
|---|
| 38 |
|
|---|
| 39 |
class Hash |
|---|
| 40 |
alias_method :blank?, :empty? |
|---|
| 41 |
end |
|---|
| 42 |
|
|---|
| 43 |
class String |
|---|
| 44 |
def blank? |
|---|
| 45 |
self !~ /\S/ |
|---|
| 46 |
end |
|---|
| 47 |
end |
|---|
| 48 |
|
|---|
| 49 |
class Numeric |
|---|
| 50 |
def blank? |
|---|
| 51 |
false |
|---|
| 52 |
end |
|---|
| 53 |
end |
|---|