Module: DaHuang::ObjectExt

Defined in:
lib/object_ext.rb

Instance Method Summary collapse

Instance Method Details

#in?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

def in?(*args)
  args.flatten.include? self
end

#is_numeric?Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
# File 'lib/object_ext.rb', line 3

def is_numeric?
  if kind_of?(Fixnum) || kind_of?(Float) || to_s.strip.match(/^[-+]?[0-9]*\.?[0-9]+$/)
    true
  else
    false
  end
end

#returning(val, &block) ⇒ Object



15
16
17
18
# File 'lib/object_ext.rb', line 15

def returning(val, &block)
  block.call val
  val
end