Class: AdequateCryptoAddress::Ada
- Inherits:
-
Object
- Object
- AdequateCryptoAddress::Ada
- Defined in:
- lib/adequate_crypto_address/ada.rb
Constant Summary collapse
- BASE_ADDRESS_TYPES =
[0, 1, 2, 3].freeze
- POINTER_ADDRESS_TYPES =
[4, 5].freeze
- ENTERPRISE_ADDRESS_TYPES =
[6, 7].freeze
- VALID_ADDRESS_TYPES =
(BASE_ADDRESS_TYPES + POINTER_ADDRESS_TYPES + ENTERPRISE_ADDRESS_TYPES).freeze
- MAX_LENGTH =
Shelley payment addresses cap at ~103 chars (base); allow headroom while still bounding work, since Bech32 decoding runs with ignore_length: true.
130
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#address_type ⇒ Object
:prod or :test when valid, otherwise nil.
-
#initialize(address) ⇒ Ada
constructor
A new instance of Ada.
- #valid?(type = nil) ⇒ Boolean
Constructor Details
#initialize(address) ⇒ Ada
Returns a new instance of Ada.
15 16 17 18 |
# File 'lib/adequate_crypto_address/ada.rb', line 15 def initialize(address) @address = address @type = detect_type end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
5 6 7 |
# File 'lib/adequate_crypto_address/ada.rb', line 5 def address @address end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/adequate_crypto_address/ada.rb', line 5 def type @type end |
Instance Method Details
#address_type ⇒ Object
:prod or :test when valid, otherwise nil.
29 30 31 |
# File 'lib/adequate_crypto_address/ada.rb', line 29 def address_type type end |
#valid?(type = nil) ⇒ Boolean
20 21 22 23 24 25 26 |
# File 'lib/adequate_crypto_address/ada.rb', line 20 def valid?(type = nil) if type address_type == type.to_sym else !address_type.nil? end end |