Class: ClassTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/parser/class_tracker.rb

Constant Summary collapse

@@classes =

Create a hash of known class definitions, we would not have to do this when I figure out how to tell if a class definition exists.

{ }

Class Method Summary collapse

Class Method Details

.<<(class_name) ⇒ Object

Adds a class to the @@classes hash using the << operator.



18
19
20
# File 'lib/parser/class_tracker.rb', line 18

def self.<<(class_name)
  @@classes[class_name.to_sym] = true
end

.exists?(class_name) ⇒ Boolean

Returns true if the named class is in @@classes.

Returns:

  • (Boolean)


13
14
15
# File 'lib/parser/class_tracker.rb', line 13

def self.exists?(class_name)
  @@classes[class_name.to_sym] == true
end

.to_sObject

return the state of each of the classes recorded in the @@classes hash, as a string.



23
24
25
26
27
28
# File 'lib/parser/class_tracker.rb', line 23

def self.to_s
  s = '{'
  @@classes.each { |k,v| s += "\n\t#{k.to_s}=>#{v.to_s},"}
  s[-1] = '' if s[-1,1] == ','[0,1]
  s << "\n}"
end