Class: RubyDictionary::Klass

Inherits:
Object
  • Object
show all
Includes:
Findable::InstanceMethods
Defined in:
lib/ruby_dictionary/klass.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Findable::InstanceMethods

#find_by_name

Constructor Details

#initialize(name = nil, definition = nil, url = nil) ⇒ Klass

Returns a new instance of Klass.



6
7
8
9
10
11
12
13
# File 'lib/ruby_dictionary/klass.rb', line 6

def initialize(name=nil,definition=nil,url=nil)
  @name = name
  @definition = definition
  @url = url
  @klass_methods = []
  @inst_methods = []
  @all_methods = []
end

Instance Attribute Details

#definitionObject

Returns the value of attribute definition.



3
4
5
# File 'lib/ruby_dictionary/klass.rb', line 3

def definition
  @definition
end

#methodObject

Returns the value of attribute method.



3
4
5
# File 'lib/ruby_dictionary/klass.rb', line 3

def method
  @method
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/ruby_dictionary/klass.rb', line 3

def name
  @name
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/ruby_dictionary/klass.rb', line 3

def url
  @url
end

Class Method Details

.allObject



25
26
27
# File 'lib/ruby_dictionary/klass.rb', line 25

def self.all
  @@all
end

.listObject



29
30
31
# File 'lib/ruby_dictionary/klass.rb', line 29

def self.list
  @@all.each{|k| k.name}
end

Instance Method Details

#add_inst_method(method) ⇒ Object



15
16
17
18
# File 'lib/ruby_dictionary/klass.rb', line 15

def add_inst_method(method)
  method.klass = self unless method.klass != nil
  @inst_methods << method unless @inst_methods.include?(method)
end

#add_klass_method(method) ⇒ Object



20
21
22
23
# File 'lib/ruby_dictionary/klass.rb', line 20

def add_klass_method(method)
  method.klass = self unless method.klass != nil
  @klass_methods << method unless @klass_methods.include?(method)
end

#all_methodsObject



41
42
43
# File 'lib/ruby_dictionary/klass.rb', line 41

def all_methods
  @all_methods
end

#clear_method_listsObject



57
58
59
60
61
# File 'lib/ruby_dictionary/klass.rb', line 57

def clear_method_lists
  @inst_methods.clear
  @klass_methods.clear
  @all_methods.clear
end

#inst_methodsObject



33
34
35
# File 'lib/ruby_dictionary/klass.rb', line 33

def inst_methods
  @inst_methods
end

#klass_methodsObject



37
38
39
# File 'lib/ruby_dictionary/klass.rb', line 37

def klass_methods
  @klass_methods
end

#list_all_methodsObject



53
54
55
# File 'lib/ruby_dictionary/klass.rb', line 53

def list_all_methods
  @all_methods.each{|m| puts m.name}
end

#list_inst_methodsObject



45
46
47
# File 'lib/ruby_dictionary/klass.rb', line 45

def list_inst_methods
  @inst_methods.each{|m| puts m.name}
end

#list_klass_methodsObject



49
50
51
# File 'lib/ruby_dictionary/klass.rb', line 49

def list_klass_methods
  @klass_methods.each{|m| puts m.name}
end