Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/small/object.rb
Instance Method Summary collapse
- #array? ⇒ Boolean
- #blank? ⇒ Boolean
- #boolean? ⇒ Boolean
- #fixnum? ⇒ Boolean
- #float? ⇒ Boolean
- #hash? ⇒ Boolean
- #integer? ⇒ Boolean
- #numeric? ⇒ Boolean
- #presence ⇒ Object
- #present? ⇒ Boolean
- #proc? ⇒ Boolean
- #string? ⇒ Boolean
- #try(*a, &b) ⇒ Object
Instance Method Details
#blank? ⇒ Boolean
39 40 41 |
# File 'lib/small/object.rb', line 39 def blank? respond_to?(:empty?) ? empty? : !self end |
#boolean? ⇒ Boolean
19 20 21 |
# File 'lib/small/object.rb', line 19 def boolean? is_a?(FalseClass) || is_a?(TrueClass) end |
#fixnum? ⇒ Boolean
23 24 25 |
# File 'lib/small/object.rb', line 23 def fixnum? is_a?(Fixnum) end |
#float? ⇒ Boolean
31 32 33 |
# File 'lib/small/object.rb', line 31 def float? is_a?(Float) end |
#numeric? ⇒ Boolean
27 28 29 |
# File 'lib/small/object.rb', line 27 def numeric? is_a?(Numeric) end |
#presence ⇒ Object
47 48 49 |
# File 'lib/small/object.rb', line 47 def presence self if present? end |
#present? ⇒ Boolean
43 44 45 |
# File 'lib/small/object.rb', line 43 def present? !blank? end |
#proc? ⇒ Boolean
35 36 37 |
# File 'lib/small/object.rb', line 35 def proc? is_a?(Proc) end |
#try(*a, &b) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/small/object.rb', line 52 def try(*a, &b) if a.empty? && block_given? yield self else __send__(*a, &b) end end |