Class: CryptoAddressValidator::Btc

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#addressObject (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

#typeObject (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

Returns:

  • (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