Class: Zold::Id
- Inherits:
-
Object
- Object
- Zold::Id
- Defined in:
- lib/zold/id.rb
Overview
Id of the wallet
Constant Summary collapse
- BANNED =
Returns a list of banned IDs, as strings
begin CSV.read(File.join(__dir__, '../../resources/banned-wallets.csv')).map { |r| r[0] } end
- ROOT =
The ID of the root wallet.
Id.new('0000000000000000')
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(id = Id.generate_id) ⇒ Id
constructor
A new instance of Id.
- #root? ⇒ Boolean
- #to_s ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(id = Id.generate_id) ⇒ Id
Returns a new instance of Id.
49 50 51 52 53 |
# 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 |
Class Method Details
Instance Method Details
#<=>(other) ⇒ Object
76 77 78 79 |
# 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) ⇒ Object
71 72 73 74 |
# 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) ⇒ Boolean
62 63 64 65 |
# 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 ⇒ Object
67 68 69 |
# File 'lib/zold/id.rb', line 67 def hash to_s.hash end |
#to_s ⇒ Object
85 86 87 |
# File 'lib/zold/id.rb', line 85 def to_s format('%016x', @id) end |
#to_str ⇒ Object
81 82 83 |
# File 'lib/zold/id.rb', line 81 def to_str to_s end |