Class: Zold::Prefixes
- Inherits:
-
Object
- Object
- Zold::Prefixes
- Defined in:
- lib/zold/prefixes.rb
Overview
Payment prefixes
Instance Method Summary collapse
- #create(length = 8) ⇒ Object
-
#initialize(wallet) ⇒ Prefixes
constructor
A new instance of Prefixes.
- #valid?(prefix) ⇒ Boolean
Constructor Details
#initialize(wallet) ⇒ Prefixes
Returns a new instance of Prefixes.
31 32 33 |
# File 'lib/zold/prefixes.rb', line 31 def initialize(wallet) @wallet = wallet end |
Instance Method Details
#create(length = 8) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/zold/prefixes.rb', line 35 def create(length = 8) raise "Length #{length} is too small" if length < 8 raise "Length #{length} is too big" if length > 32 key = body start = Random.new.rand(key.length - length) key[start..(start + length - 1)] end |
#valid?(prefix) ⇒ Boolean
43 44 45 |
# File 'lib/zold/prefixes.rb', line 43 def valid?(prefix) body.include?(prefix) end |