Class: RSwim::Directory

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

Instance Method Summary collapse

Constructor Details

#initializeDirectory

Returns a new instance of Directory.



5
6
7
8
9
# File 'lib/rswim/directory.rb', line 5

def initialize
  @i = 0
  @ids = {}
  @hosts = {}
end

Instance Method Details

#host(id) ⇒ Object



23
24
25
# File 'lib/rswim/directory.rb', line 23

def host(id)
  @hosts[id]
end

#id(host) ⇒ Object



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

def id(host)
  result = @ids[host]
  if result.nil?
    @i += 1
    @ids[host] = @i
    @hosts[@i] = host
    @i
  else
    result
  end
end