Class: Talk::RegistryEntry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, file = nil, line = nil) ⇒ RegistryEntry

Returns a new instance of RegistryEntry.



13
14
15
16
17
18
# File 'lib/registry.rb', line 13

def initialize(name=nil, file=nil, line=nil)
  @file = file
  @line = line
  @name = name
  @children = {}
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



11
12
13
# File 'lib/registry.rb', line 11

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



11
12
13
# File 'lib/registry.rb', line 11

def line
  @line
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/registry.rb', line 11

def name
  @name
end

Instance Method Details

#[](key) ⇒ Object



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

def [](key)
  @children[key]
end

#[]=(key, value) ⇒ Object



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

def []=(key, value)
  @children[key] = value
end

#each(&block) ⇒ Object



38
39
40
# File 'lib/registry.rb', line 38

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

#has_children?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/registry.rb', line 42

def has_children?
  not @children.empty?
end

#is_entry?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/registry.rb', line 46

def is_entry?
  @file != nil
end

#keysObject



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

def keys
  @children.keys
end

#make_entry(name, file, line) ⇒ Object



20
21
22
23
24
# File 'lib/registry.rb', line 20

def make_entry(name, file, line)
  @name = name
  @file = file
  @line = line
end

#to_sObject



50
51
52
# File 'lib/registry.rb', line 50

def to_s
  is_entry? ? "#{@file}:#{@line}" : "container"
end