Class: Z4BC::Lvls
- Inherits:
-
Object
- Object
- Z4BC::Lvls
- Defined in:
- lib/z4blockchain.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #incr(u) ⇒ Object
-
#initialize(i) ⇒ Lvls
constructor
A new instance of Lvls.
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
#id ⇒ Object
Returns the value of attribute id.
203 204 205 |
# File 'lib/z4blockchain.rb', line 203 def id @id end |
#user ⇒ Object (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 |