Class: RSwim::Directory
- Inherits:
-
Object
- Object
- RSwim::Directory
- Defined in:
- lib/rswim/directory.rb
Instance Method Summary collapse
- #host(id) ⇒ Object
- #id(host) ⇒ Object
-
#initialize ⇒ Directory
constructor
A new instance of Directory.
Constructor Details
#initialize ⇒ Directory
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 |