Class: Controlrepo::Class

Inherits:
Object
  • Object
show all
Defined in:
lib/controlrepo/class.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Class

Returns a new instance of Class.



6
7
8
9
# File 'lib/controlrepo/class.rb', line 6

def initialize(name)
  @name = name
  @@all << self
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/controlrepo/class.rb', line 5

def name
  @name
end

Class Method Details

.allObject



24
25
26
# File 'lib/controlrepo/class.rb', line 24

def self.all
  @@all
end

.find(class_name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/controlrepo/class.rb', line 11

def self.find(class_name)
  @@all.each do |cls|
    if class_name.is_a?(Controlrepo::Class)
      if cls = class_name
        return cls
      end
    elsif cls.name == class_name
      return cls
    end
  end
  nil
end