Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/sugar-high/dsl.rb,
lib/sugar-high/not.rb,
lib/sugar-high/kind_of.rb,
lib/sugar-high/methods.rb,
lib/sugar-high/metaclass.rb
Defined Under Namespace
Classes: Not
Class Method Summary collapse
Instance Method Summary collapse
- #any_kind_of?(*kinds) ⇒ Boolean
- #get_methods(*types) ⇒ Object
- #kind_of_label? ⇒ Boolean
- #kind_of_number? ⇒ Boolean
- #kind_of_symbol? ⇒ Boolean
- #kinda_file? ⇒ Boolean
- #not_any_kind_of?(*kinds) ⇒ Boolean
- #with(instance, *args, &block) ⇒ Object
Class Method Details
.metaclass ⇒ Object
2 3 4 |
# File 'lib/sugar-high/metaclass.rb', line 2 def self. class << self; self; end end |
Instance Method Details
#any_kind_of?(*kinds) ⇒ Boolean
9 10 11 12 13 14 |
# File 'lib/sugar-high/kind_of.rb', line 9 def any_kind_of? *kinds kinds.all_kinds.each do |kind| return true if self.kind_of? kind end false end |
#get_methods(*types) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/sugar-high/methods.rb', line 2 def get_methods *types types.inject([]) do |list, type| list << case type when :all get_methods(:private, :protected, :public) when :private, :protected, :public send :"#{type}_methods" end list.flatten end.flatten.uniq end |
#kind_of_label? ⇒ Boolean
23 24 25 |
# File 'lib/sugar-high/kind_of.rb', line 23 def kind_of_label? self.any_kind_of? String, Symbol end |
#kind_of_number? ⇒ Boolean
27 28 29 |
# File 'lib/sugar-high/kind_of.rb', line 27 def kind_of_number? self.any_kind_of? Numeric end |
#kind_of_symbol? ⇒ Boolean
32 33 34 |
# File 'lib/sugar-high/kind_of.rb', line 32 def kind_of_symbol? self.any_kind_of? Symbols, Symbol end |
#kinda_file? ⇒ Boolean
5 6 7 |
# File 'lib/sugar-high/kind_of.rb', line 5 def kinda_file? any_kind_of?(File, Dir) end |
#not_any_kind_of?(*kinds) ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/sugar-high/kind_of.rb', line 16 def not_any_kind_of? *kinds kinds.all_kinds.each do |kind| return false if self.kind_of? kind end true end |
#with(instance, *args, &block) ⇒ Object
2 3 4 5 |
# File 'lib/sugar-high/dsl.rb', line 2 def with(instance, *args, &block) instance.instance_exec(*args, &block) instance end |