Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/hobosupport.rb,
lib/hobosupport/metaid.rb,
lib/hobosupport/enumerable.rb,
lib/hobosupport/methodcall.rb
Overview
Thanks to _why
Instance Method Summary collapse
- #_? ⇒ Boolean
- #in?(enum) ⇒ Boolean
- #is_a?(*args) ⇒ Boolean
-
#is_a_without_multiple_args? ⇒ Object
Often nice to ask e.g.
-
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass.
- #meta_eval(src = nil, &blk) ⇒ Object
- #metaclass ⇒ Object
- #metaclass_eval(src = nil, &blk) ⇒ Object
- #not_in?(enum) ⇒ Boolean
- #try ⇒ Object
Instance Method Details
#_? ⇒ Boolean
13 14 15 |
# File 'lib/hobosupport/methodcall.rb', line 13 def _?() self end |
#in?(enum) ⇒ Boolean
84 85 86 |
# File 'lib/hobosupport/enumerable.rb', line 84 def in?(enum) enum.include?(self) end |
#is_a?(*args) ⇒ Boolean
25 26 27 |
# File 'lib/hobosupport.rb', line 25 def is_a?(*args) args.any? {|a| is_a_without_multiple_args?(a) } end |
#is_a_without_multiple_args? ⇒ Object
Often nice to ask e.g. some_object.is_a?(Symbol, String)
24 |
# File 'lib/hobosupport.rb', line 24 alias_method :is_a_without_multiple_args?, :is_a? |
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass
24 25 26 |
# File 'lib/hobosupport/metaid.rb', line 24 def (name, &blk) { define_method name, &blk } end |
#meta_eval(src = nil, &blk) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/hobosupport/metaid.rb', line 7 def (src=nil, &blk) if src .instance_eval(src) else .instance_eval &blk end end |
#metaclass ⇒ Object
5 |
# File 'lib/hobosupport/metaid.rb', line 5 def ; class << self; self; end; end |
#metaclass_eval(src = nil, &blk) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/hobosupport/metaid.rb', line 15 def (src=nil, &blk) if src .class_eval(src) else .class_eval &blk end end |
#not_in?(enum) ⇒ Boolean
88 89 90 |
# File 'lib/hobosupport/enumerable.rb', line 88 def not_in?(enum) not enum.include?(self) end |
#try ⇒ Object
17 18 19 |
# File 'lib/hobosupport/methodcall.rb', line 17 def try CallIfAvailable.new(self) end |