Module: DaHuang::ObjectExt

Defined in:
lib/object_ext.rb

Instance Method Summary collapse

Instance Method Details

#in?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

def in?(*args)
  raise %(An object cannot be "in" a #{ary.class.name}) unless ary.is_a? Array
  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



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

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