Module: Address
Class Method Summary collapse
Instance Method Summary collapse
- #_add(value) ⇒ Object
-
#_sub(value) ⇒ Object
private (internal use only) methods - PLEASE do NOT use (use transfer/send).
- #address ⇒ Object
- #balance ⇒ Object
- #send(value) ⇒ Object
-
#transfer(value) ⇒ Object
method address.
Class Method Details
.zero ⇒ Object
16 |
# File 'lib/universum/universum.rb', line 16 def self.zero() '0x0000'; end |
Instance Method Details
#_add(value) ⇒ Object
56 57 58 59 |
# File 'lib/universum/universum.rb', line 56 def _add( value ) @balance ||= 0 ## return 0 if undefined @balance += value end |
#_sub(value) ⇒ Object
private (internal use only) methods - PLEASE do NOT use (use transfer/send)
51 52 53 54 |
# File 'lib/universum/universum.rb', line 51 def _sub( value ) @balance ||= 0 ## return 0 if undefined @balance -= value end |
#address ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/universum/universum.rb', line 18 def address if @address @address else if is_a? Contract ## fix/todo: use/lookup proper addr from contract ## construct address for now from object_id "0x#{(object_id << 1).to_s(16)}" else ## assume Account '0x0000' end end end |
#balance ⇒ Object
46 47 48 |
# File 'lib/universum/universum.rb', line 46 def balance @balance ||= 0 ## return 0 if undefined end |
#send(value) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/universum/universum.rb', line 37 def send( value ) ## @payable @public ## todo/fix: assert value > 0 ## todo/fix: add missing -= part in transfer!!!! ## use this (current contract) for debit (-) ammount this._sub( value ) # sub(tract) / debit from the sender (current contract) _add( value ) # add / credit to the recipient end |
#transfer(value) ⇒ Object
method address
32 33 34 35 |
# File 'lib/universum/universum.rb', line 32 def transfer( value ) ## @payable @public ## todo/fix: throw exception if insufficient funds send( value ) # returns true/false end |