Class: TomDoc::Scope

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/tomdoc/scope.rb

Overview

A Scope is a Module or Class. It may contain other scopes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, comment = '', instance_methods = [], class_methods = []) ⇒ Scope

Returns a new instance of Scope.



10
11
12
13
14
15
16
# File 'lib/tomdoc/scope.rb', line 10

def initialize(name, comment = '', instance_methods = [], class_methods = [])
  @name = name
  @comment = comment
  @instance_methods = instance_methods
  @class_methods = class_methods
  @scopes = {}
end

Instance Attribute Details

#class_methodsObject

Returns the value of attribute class_methods.



7
8
9
# File 'lib/tomdoc/scope.rb', line 7

def class_methods
  @class_methods
end

#commentObject

Returns the value of attribute comment.



7
8
9
# File 'lib/tomdoc/scope.rb', line 7

def comment
  @comment
end

#instance_methodsObject

Returns the value of attribute instance_methods.



7
8
9
# File 'lib/tomdoc/scope.rb', line 7

def instance_methods
  @instance_methods
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/tomdoc/scope.rb', line 7

def name
  @name
end

#scopesObject

Returns the value of attribute scopes.



8
9
10
# File 'lib/tomdoc/scope.rb', line 8

def scopes
  @scopes
end

Instance Method Details

#[](scope) ⇒ Object



22
23
24
# File 'lib/tomdoc/scope.rb', line 22

def [](scope)
  @scopes[scope]
end

#each(&block) ⇒ Object



30
31
32
# File 'lib/tomdoc/scope.rb', line 30

def each(&block)
  @scopes.each(&block)
end

#inspectObject



38
39
40
41
42
43
44
# File 'lib/tomdoc/scope.rb', line 38

def inspect
  scopes = @scopes.keys.join(', ')
  imethods = @instance_methods.inspect
  cmethods = @class_methods.inspect

  "<#{name} scopes:[#{scopes}] :#{cmethods}: ##{imethods}#>"
end

#keysObject



26
27
28
# File 'lib/tomdoc/scope.rb', line 26

def keys
  @scopes.keys
end

#to_sObject



34
35
36
# File 'lib/tomdoc/scope.rb', line 34

def to_s
  inspect
end

#tomdocObject



18
19
20
# File 'lib/tomdoc/scope.rb', line 18

def tomdoc
  @tomdoc ||= TomDoc.new(@comment)
end