Class: SystemNavigation::RubyEnvironment Private

Inherits:
Object
  • Object
show all
Defined in:
lib/system_navigation/ruby_environment.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#all_behaviors(&block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute block on each class, metaclass, module and module’s metaclass.

Returns:

  • (Enumerator)

    if block was given

  • (Enumerator)

    if block is missing

Since:

  • 0.1.0



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/system_navigation/ruby_environment.rb', line 10

def all_behaviors(&block)
  enum = Enumerator.new do |y|
    ObjectSpace.each_object(Module) do |klass|
      y.yield klass
      y.yield klass.singleton_class
    end
  end

  if block_given?
    enum.each(&block)
  else
    enum
  end
end

#all_classes(&block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute block on each class (but not its metaclass).

Returns:

  • (Enumerator)

    if block was given

  • (Enumerator)

    if block is missing

Since:

  • 0.1.0



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/system_navigation/ruby_environment.rb', line 30

def all_classes(&block)
  enum = Enumerator.new do |y|
    ObjectSpace.each_object(Class) do |klass|
      y.yield klass
    end
  end

  if block_given?
    enum.each(&block)
  else
    enum
  end
end

#all_classes_and_modules(&block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute block on each class and module (but not their metaclasses).

Returns:

  • (Enumerator)

    if block was given

  • (Enumerator)

    if block is missing

Since:

  • 0.1.0



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/system_navigation/ruby_environment.rb', line 49

def all_classes_and_modules(&block)
  enum = Enumerator.new do |y|
    ObjectSpace.each_object(Module) do |klass|
      y.yield klass
    end
  end

  if block_given?
    enum.each(&block)
  else
    enum
  end
end

#all_modules(&block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute block on each module (but not its metaclass).

Returns:

  • (Enumerator)

    if block was given

  • (Enumerator)

    if block is missing

Since:

  • 0.1.0



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/system_navigation/ruby_environment.rb', line 68

def all_modules(&block)
  enum = Enumerator.new do |y|
    self.all_classes_and_modules.each do |klass|
      y.yield(klass) if klass.instance_of?(Module)
    end
  end

  if block_given?
    enum.each(&block)
  else
    enum
  end
end

#all_objects(&block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute block on each object.

Returns:

  • (Enumerator)

    if block was given

  • (Enumerator)

    if block is missing

Since:

  • 0.1.0



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/system_navigation/ruby_environment.rb', line 87

def all_objects(&block)
  enum = Enumerator.new do |y|
    ObjectSpace.each_object do |obj|
      y.yield obj
    end
  end

  if block_given?
    enum.each(&block)
  else
    enum
  end
end