Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/a_types/core_ext/boolean.rb,
lib/a_types/core_ext/numeric.rb,
lib/a_types/core_ext/enumerable.rb
Overview
Adds #blank? if not already defined and #filled? as opposite method.
Instance Method Summary collapse
-
#blank? ⇒ true, false
Checks whether the object is nil or has no content.
-
#filled? ⇒ true, false
Checks whether the object has any content.
-
#to_bool ⇒ true
(also: #to_b, #to_bool!, #to_b!)
Respecting the Ruby way.
-
#to_num ⇒ Object
Nil.
Instance Method Details
#blank? ⇒ true, false
Checks whether the object is nil or has no content.
7 8 9 |
# File 'lib/a_types/core_ext/enumerable.rb', line 7 def blank? respond_to?(:empty?) ? empty? : nil? end |
#filled? ⇒ true, false
Checks whether the object has any content.
14 15 16 |
# File 'lib/a_types/core_ext/enumerable.rb', line 14 def filled? !blank? end |
#to_bool ⇒ true Also known as: to_b, to_bool!, to_b!
Returns respecting the Ruby way.
71 72 73 |
# File 'lib/a_types/core_ext/boolean.rb', line 71 def to_bool !nil? end |
#to_num ⇒ Object
Returns nil.
7 8 9 |
# File 'lib/a_types/core_ext/numeric.rb', line 7 def to_num nil end |