Module: Iota

Defined in:
lib/iota.rb

Constant Summary collapse

@@iota =
-1

Instance Method Summary collapse

Instance Method Details

#iota(names = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/iota.rb', line 4

def iota(names = nil)
  if names.nil?
    @@iota += 1
    return @@iota
  end
  
  values = []
  names.each do |name|
    @@iota += 1
    if block_given?
      Iota.const_set name, yield(@@iota)
    else
      Iota.const_set name, @@iota
    end
    values << Iota.const_get(name.to_sym)
  end
  values
end

#set_iota(value = 0) ⇒ Object



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

def set_iota(value = 0)
  @@iota = value - 1
end