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

Class Method Details

.metaclassObject



2
3
4
# File 'lib/sugar-high/metaclass.rb', line 2

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

Instance Method Details

#any_kind_of?(*kinds) ⇒ Boolean

Returns:



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

Returns:



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

Returns:



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

Returns:



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

Returns:



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

Returns:



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