Class: Account
- Inherits:
-
Object
- Object
- Account
- Defined in:
- lib/universum/account.rb
Constant Summary collapse
- @@directory =
{}
Instance Attribute Summary collapse
-
#tx ⇒ Object
readonly
Returns the value of attribute tx.
Class Method Summary collapse
- .[](key) ⇒ Object
- .all ⇒ Object
-
.at(key) ⇒ Object
another “classic” alias for find_by_address.
-
.find(key) ⇒ Object
make find_by_address the default finder.
- .find_by_address(key) ⇒ Object
Instance Method Summary collapse
-
#_auto_inc_tx ⇒ Object
“internal” method - (auto) increment transaction (tx) counter.
-
#address ⇒ Object
account (builtin) services / transaction methods.
-
#address_hex ⇒ Object
add convenience shortcut address_hex - why? why not?.
-
#balance ⇒ Object
note: add convenience shortcut - why? why not?.
-
#balance=(value) ⇒ Object
note: for now allow write access too!!!.
Instance Attribute Details
#tx ⇒ Object (readonly)
Returns the value of attribute tx.
44 45 46 |
# File 'lib/universum/account.rb', line 44 def tx @tx end |
Class Method Details
.[](key) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/universum/account.rb', line 15 def self.[]( key ) o = find_by_address( key ) if o o else o = new( key ) ## note: auto-register (new) address in (yellow page) directory @@directory[ key ] = o o end end |
.all ⇒ Object
27 |
# File 'lib/universum/account.rb', line 27 def self.all() @@directory.values; end |
.at(key) ⇒ Object
another “classic” alias for find_by_address
13 |
# File 'lib/universum/account.rb', line 13 def self.at( key) find_by_address( key ); end |
.find(key) ⇒ Object
make find_by_address the default finder
12 |
# File 'lib/universum/account.rb', line 12 def self.find( key ) find_by_address( key ); end |
.find_by_address(key) ⇒ Object
7 8 9 10 11 |
# File 'lib/universum/account.rb', line 7 def self.find_by_address( key ) ## clean key (allow "embedded" name e.g 0x1111 (Alice)) key = key.gsub(/\(.+\)/, '' ).strip @@directory[ key ] end |
Instance Method Details
#_auto_inc_tx ⇒ Object
“internal” method - (auto) increment transaction (tx) counter
45 |
# File 'lib/universum/account.rb', line 45 def _auto_inc_tx() @tx += 1; end |
#address ⇒ Object
account (builtin) services / transaction methods
34 |
# File 'lib/universum/account.rb', line 34 def address() @address; end |
#address_hex ⇒ Object
add convenience shortcut address_hex - why? why not?
35 |
# File 'lib/universum/account.rb', line 35 def address_hex() @address.hex; end |
#balance ⇒ Object
note: add convenience shortcut - why? why not?
37 |
# File 'lib/universum/account.rb', line 37 def balance() @address.balance; end |
#balance=(value) ⇒ Object
note: for now allow write access too!!!
39 40 41 |
# File 'lib/universum/account.rb', line 39 def balance=( value ) @address.send( '@balance=', value ) end |