class Zold::Id
Id
of the wallet
Constants
- BANNED
Returns a list of banned IDs, as strings
- PTN
Pattern to match the ID
- ROOT
The ID of the root wallet.
Public Class Methods
generate_id()
click to toggle source
# File lib/zold/id.rb, line 41 def self.generate_id loop do id = format('%016x', rand(2**32..2**64 - 1)) next if Id::BANNED.include?(id) return id end end
new(id = Id.generate_id)
click to toggle source
# File lib/zold/id.rb, line 49 def initialize(id = Id.generate_id) raise "Invalid wallet ID type: #{id.class.name}" unless id.is_a?(String) raise "Invalid wallet ID: #{id}" unless PTN.match?(id) @id = Integer("0x#{id}", 16) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/zold/id.rb, line 76 def <=>(other) raise 'Can only compare with Id' unless other.is_a?(Id) to_s <=> other.to_s end
==(other)
click to toggle source
# File lib/zold/id.rb, line 71 def ==(other) raise 'Can only compare with Id' unless other.is_a?(Id) to_s == other.to_s end
eql?(other)
click to toggle source
# File lib/zold/id.rb, line 62 def eql?(other) raise 'Can only compare with Id' unless other.is_a?(Id) to_s == other.to_s end
hash()
click to toggle source
# File lib/zold/id.rb, line 67 def hash to_s.hash end
root?()
click to toggle source
# File lib/zold/id.rb, line 58 def root? to_s == ROOT.to_s end
to_s()
click to toggle source
# File lib/zold/id.rb, line 85 def to_s format('%016x', @id) end
to_str()
click to toggle source
# File lib/zold/id.rb, line 81 def to_str to_s end