Class: Z4BC::User
- Inherits:
-
Object
- Object
- Z4BC::User
- Defined in:
- lib/z4blockchain.rb
Instance Attribute Summary collapse
-
#game ⇒ Object
readonly
Returns the value of attribute game.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lvls ⇒ Object
readonly
Returns the value of attribute lvls.
-
#wins ⇒ Object
readonly
Returns the value of attribute wins.
Instance Method Summary collapse
-
#initialize(i) ⇒ User
constructor
A new instance of User.
- #to_h ⇒ Object
Constructor Details
#initialize(i) ⇒ User
Returns a new instance of User.
140 141 142 143 144 145 |
# File 'lib/z4blockchain.rb', line 140 def initialize i @id = i @game = PStore.new("db/player-game-#{i}.pstore") @wins = PStore.new("db/player-wins-#{i}.pstore") @lvls = PStore.new("db/player-lvls-#{i}.pstore") end |
Instance Attribute Details
#game ⇒ Object (readonly)
Returns the value of attribute game.
138 139 140 |
# File 'lib/z4blockchain.rb', line 138 def game @game end |
#id ⇒ Object
Returns the value of attribute id.
136 137 138 |
# File 'lib/z4blockchain.rb', line 136 def id @id end |
#lvls ⇒ Object (readonly)
Returns the value of attribute lvls.
138 139 140 |
# File 'lib/z4blockchain.rb', line 138 def lvls @lvls end |
#wins ⇒ Object (readonly)
Returns the value of attribute wins.
138 139 140 |
# File 'lib/z4blockchain.rb', line 138 def wins @wins end |
Instance Method Details
#to_h ⇒ Object
147 148 149 150 151 152 153 |
# File 'lib/z4blockchain.rb', line 147 def to_h h = { game: {}, wins: {}, lvls: {} } @game.transaction { |db| db.keys.each { |e| h[:game][e] = db[e] } } @wins.transaction { |db| db.keys.each { |e| h[:wins][e] = db[e] } } @lvls.transaction { |db| db.keys.each { |e| h[:lvls][e] = db[e] } } return h end |