Class: Z4BC::Lvls

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(i) ⇒ Lvls

Returns a new instance of Lvls.



207
208
209
210
# File 'lib/z4blockchain.rb', line 207

def initialize i
  @id = i
  @user = PStore.new("lvls-user-#{i}")
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



203
204
205
# File 'lib/z4blockchain.rb', line 203

def id
  @id
end

#userObject (readonly)

Returns the value of attribute user.



205
206
207
# File 'lib/z4blockchain.rb', line 205

def user
  @user
end

Instance Method Details

#incr(u) ⇒ Object



211
212
213
214
# File 'lib/z4blockchain.rb', line 211

def incr u
  @user.transaction { |db| x = db[u].to_i; db[u] = x + 1; }
  LVLS.transaction { |db| x = db[@id].to_i; db[@id] = x + 1 }
end