class LedgerLite::Ledger
Public Instance Methods
send( from, to, amount )
click to toggle source
apply/do single transaction - send payment - do transfer
- find a different name - why? why not?
# File lib/ledger-lite/base.rb, line 169 def send( from, to, amount ) if sufficient?( from, amount ) if self.class.config.coinbase?( from ) # note: coinbase has unlimited funds!! ("virtual" built-in money printing address) else @addr[ from ] -= amount end @addr[ to ] ||= 0 @addr[ to ] += amount end end
Also aliased as: transfer
sufficient?( addr, amount )
click to toggle source
find a better name - why? why not?
e.g. use can? funds? sufficient? has_funds?
# File lib/ledger-lite/base.rb, line 156 def sufficient?( addr, amount ) return true if self.class.config.coinbase?( addr ) ## note: coinbase has unlimited funds!!! @addr.has_key?( addr ) && @addr[addr] - amount >= 0 end
Also aliased as: sufficient_funds?
sufficient_funds?( addr, amount )
note: sufficient_funds? is an alias for sufficient?
Alias for: sufficient?
unpack( tx )
click to toggle source
# File lib/ledger-lite/base.rb, line 134 def unpack( tx ) ## "unpack" from, to, amount values puts "unpack:" pp tx if tx.is_a?( Hash ) ## support hashes from = tx[:from] to = tx[:to] amount = tx[:amount] else ## assume it's a transaction (tx) struct/class from = tx.from to = tx.to amount = tx.amount end [from,to,amount] end