Class: Ibancom::Resources::IBAN::Validation

Inherits:
Base
  • Object
show all
Defined in:
lib/ibancom/resources/iban/validation.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

map

Constructor Details

#initialize(response, attributes = {}) ⇒ Validation

Returns a new instance of Validation.



11
12
13
14
15
16
# File 'lib/ibancom/resources/iban/validation.rb', line 11

def initialize(response, attributes = {})
  super(response, attributes)
  @bank = Bank.new(response, attributes[:bank_data])
  @checks = Checks.new(response, attributes[:validations])
  @schemes = Schemes.new(response, attributes[:sepa_data])
end

Instance Attribute Details

#bankObject (readonly)

Returns the value of attribute bank.



7
8
9
# File 'lib/ibancom/resources/iban/validation.rb', line 7

def bank
  @bank
end

#checksObject (readonly)

Returns the value of attribute checks.



7
8
9
# File 'lib/ibancom/resources/iban/validation.rb', line 7

def checks
  @checks
end

#schemesObject (readonly)

Returns the value of attribute schemes.



7
8
9
# File 'lib/ibancom/resources/iban/validation.rb', line 7

def schemes
  @schemes
end

Instance Method Details

#failed_checksObject



22
23
24
# File 'lib/ibancom/resources/iban/validation.rb', line 22

def failed_checks
  checks.select(&:failed?)
end

#supported_scheme?(code) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
# File 'lib/ibancom/resources/iban/validation.rb', line 30

def supported_scheme?(code)
  scheme = supported_schemes.find { |supported| supported.code == code }

  return false if scheme.nil?

  scheme.supported?
end

#supported_schemesObject



26
27
28
# File 'lib/ibancom/resources/iban/validation.rb', line 26

def supported_schemes
  schemes.select(&:supported?)
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ibancom/resources/iban/validation.rb', line 18

def valid?
  checks.all?(&:passed?)
end