Class: Zold::Id
- Inherits:
-
Object
- Object
- Zold::Id
- Defined in:
- lib/zold/id.rb
Overview
Id of the wallet
Constant Summary collapse
- ROOT =
Id.new('0000000000000000')
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(id = nil) ⇒ Id
constructor
A new instance of Id.
- #to_s ⇒ Object
Constructor Details
#initialize(id = nil) ⇒ Id
Returns a new instance of Id.
28 29 30 31 32 33 34 35 |
# File 'lib/zold/id.rb', line 28 def initialize(id = nil) if id.nil? @id = rand(2**32..2**64 - 1) else raise "Invalid wallet ID '#{id}'" unless id =~ /[0-9a-fA-F]{16}/ @id = Integer("0x#{id}", 16) end end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 |
# File 'lib/zold/id.rb', line 39 def==(other) to_s == other.to_s end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/zold/id.rb', line 43 def to_s format('%016x', @id) end |