Class: Object

Inherits:
BasicObject
Defined in:
lib/small/object.rb

Instance Method Summary collapse

Instance Method Details

#array?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/small/object.rb', line 3

def array?
  is_a?(Array)
end

#blank?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/small/object.rb', line 39

def blank?
  respond_to?(:empty?) ? empty? : !self
end

#boolean?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/small/object.rb', line 19

def boolean?
  is_a?(FalseClass) || is_a?(TrueClass)
end

#fixnum?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/small/object.rb', line 23

def fixnum?
  is_a?(Fixnum)
end

#float?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/small/object.rb', line 31

def float?
  is_a?(Float)
end

#hash?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/small/object.rb', line 7

def hash?
  is_a?(Hash)
end

#integer?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/small/object.rb', line 15

def integer?
  is_a?(Integer)
end

#numeric?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/small/object.rb', line 27

def numeric?
  is_a?(Numeric)
end

#presenceObject



47
48
49
# File 'lib/small/object.rb', line 47

def presence
  self if present?
end

#present?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/small/object.rb', line 43

def present?
  !blank?
end

#proc?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/small/object.rb', line 35

def proc?
  is_a?(Proc)
end

#string?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/small/object.rb', line 11

def string?
  is_a?(String)
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