Class: CryptoAddressValidator::Altcoin

Inherits:
Object
  • Object
show all
Defined in:
lib/crypto_address_validator/altcoin.rb

Overview

simple class for common altcoin addresses like legacy btc, ripple, dash, zec, etc.

Direct Known Subclasses

Dash, Ltc, Xrp, Zec

Constant Summary collapse

EXPECTED_LENGTH =
50
ADDRESS_TYPES =
{}.freeze
ALPHABET_TYPE =
:bitcoin

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address) ⇒ Altcoin

Returns a new instance of Altcoin.



13
14
15
16
# File 'lib/crypto_address_validator/altcoin.rb', line 13

def initialize(address)
  @address = address
  @type = address_type
end

Instance Attribute Details

#addressObject (readonly) Also known as: raw_address

Returns the value of attribute address.



10
11
12
# File 'lib/crypto_address_validator/altcoin.rb', line 10

def address
  @address
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/crypto_address_validator/altcoin.rb', line 10

def type
  @type
end

Instance Method Details

#valid?(validated_type = nil) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
# File 'lib/crypto_address_validator/altcoin.rb', line 18

def valid?(validated_type = nil)
  if validated_type
    type == validated_type.to_sym
  else
    !type.nil?
  end
end