Class: CryptoAddressValidator::Btc
- Inherits:
-
Object
- Object
- CryptoAddressValidator::Btc
- Defined in:
- lib/crypto_address_validator/btc.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
(also: #raw_address)
readonly
Returns the value of attribute address.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(address) ⇒ Btc
constructor
A new instance of Btc.
- #valid?(types = nil) ⇒ Boolean
Constructor Details
#initialize(address) ⇒ Btc
Returns a new instance of Btc.
8 9 10 11 |
# File 'lib/crypto_address_validator/btc.rb', line 8 def initialize(address) @address = address @type = address_type end |
Instance Attribute Details
#address ⇒ Object (readonly) Also known as: raw_address
Returns the value of attribute address.
5 6 7 |
# File 'lib/crypto_address_validator/btc.rb', line 5 def address @address end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/crypto_address_validator/btc.rb', line 5 def type @type end |
Instance Method Details
#valid?(types = nil) ⇒ Boolean
13 14 15 16 17 18 19 20 |
# File 'lib/crypto_address_validator/btc.rb', line 13 def valid?(types = nil) if types types = [types].flatten.map(&:to_sym) types.include?(address_type) else !address_type.nil? end end |