Class: Ledger
- Inherits:
-
Object
- Object
- Ledger
- Defined in:
- lib/tulipmania/ledger.rb
Instance Attribute Summary collapse
-
#wallets ⇒ Object
readonly
use addresses - why? why not? for now single address wallet (wallet==address).
Instance Method Summary collapse
-
#initialize(chain = []) ⇒ Ledger
constructor
A new instance of Ledger.
- #sufficient_tulips?(wallet, qty, what) ⇒ Boolean
Constructor Details
#initialize(chain = []) ⇒ Ledger
5 6 7 8 9 10 |
# File 'lib/tulipmania/ledger.rb', line 5 def initialize( chain=[] ) @wallets = {} chain.each do |block| apply_transactions( block.transactions ) end end |
Instance Attribute Details
#wallets ⇒ Object (readonly)
use addresses - why? why not? for now single address wallet (wallet==address)
3 4 5 |
# File 'lib/tulipmania/ledger.rb', line 3 def wallets @wallets end |
Instance Method Details
#sufficient_tulips?(wallet, qty, what) ⇒ Boolean
12 13 14 15 16 17 18 |
# File 'lib/tulipmania/ledger.rb', line 12 def sufficient_tulips?( wallet, qty, what ) return true if Tulipmania.config.coinbase?( wallet ) @wallets.has_key?( wallet ) && @wallets[wallet].has_key?( what ) && @wallets[wallet][what] - qty >= 0 end |