Class: Object

Inherits:
BasicObject
Defined in:
lib/hobo_support.rb,
lib/hobo_support/metaid.rb,
lib/hobo_support/enumerable.rb,
lib/hobo_support/methodcall.rb

Overview

Thanks to _why

Instance Method Summary collapse

Instance Method Details

#_?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/hobo_support/methodcall.rb', line 26

def _?()
  self
end

#in?(enum) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/hobo_support/enumerable.rb', line 81

def in?(enum)
  !enum.nil? && enum.include?(self)
end

#is_one_of?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

def is_one_of?(*args)
  args.any? {|a| is_a?(a) }
end

#meta_def(name, &blk) ⇒ Object

Adds methods to a metaclass



24
25
26
# File 'lib/hobo_support/metaid.rb', line 24

def meta_def(name, &blk)
  meta_eval { define_method name, &blk }
end

#meta_eval(src = nil, &blk) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/hobo_support/metaid.rb', line 7

def meta_eval(src=nil, &blk)
  if src
    metaclass.instance_eval(src)
  else
    metaclass.instance_eval &blk
  end
end

#metaclassObject



5
# File 'lib/hobo_support/metaid.rb', line 5

def metaclass; class << self; self; end; end

#metaclass_eval(src = nil, &blk) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/hobo_support/metaid.rb', line 15

def metaclass_eval(src=nil, &blk)
  if src
    metaclass.class_eval(src)
  else
    metaclass.class_eval &blk
  end
end

#not_in?(enum) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/hobo_support/enumerable.rb', line 85

def not_in?(enum)
  enum.nil? || !enum.include?(self)
end

#try(*args, &block) ⇒ Object



30
31
32
# File 'lib/hobo_support/methodcall.rb', line 30

def try(*args, &block)
  HoboSupport.hobo_try(self, *args, &block)
end