Class: Account

Inherits:
Object
  • Object
show all
Includes:
Address
Defined in:
lib/universum/universum.rb

Constant Summary collapse

@@directory =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Address

#_add, #_sub, #address, #balance, #send, #transfer, zero

Instance Attribute Details

#txObject (readonly)

Returns the value of attribute tx.



172
173
174
# File 'lib/universum/universum.rb', line 172

def tx
  @tx
end

Class Method Details

.[](key) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
# File 'lib/universum/universum.rb', line 148

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

.allObject



160
# File 'lib/universum/universum.rb', line 160

def self.all()  @@directory.values;  end

.at(key) ⇒ Object

another “classic” alias for find_by_address



146
# File 'lib/universum/universum.rb', line 146

def self.at( key) find_by_address( key ); end

.find(key) ⇒ Object

make find_by_address the default finder



145
# File 'lib/universum/universum.rb', line 145

def self.find( key ) find_by_address( key ); end

.find_by_address(key) ⇒ Object



140
141
142
143
144
# File 'lib/universum/universum.rb', line 140

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_txObject

“internal” method - (auto) increment transaction (tx) counter



173
# File 'lib/universum/universum.rb', line 173

def _auto_inc_tx() @tx += 1; end

#balance=(value) ⇒ Object

note: for now allow write access too!!!



168
169
170
# File 'lib/universum/universum.rb', line 168

def balance=( value )
  @balance = value
end

#thisObject

note: needed by transfer/send



176
# File 'lib/universum/universum.rb', line 176

def this()       Universum.this;         end