Class: Israeli::BankAccountResult
- Defined in:
- lib/israeli/result.rb
Overview
Result object for bank account validation with format detection.
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Attributes inherited from Result
#normalized, #original, #reason
Instance Method Summary collapse
-
#domestic? ⇒ Boolean
True if this is a domestic account.
-
#formatted(style: :domestic) ⇒ String?
Format the bank account.
-
#iban? ⇒ Boolean
True if this is an IBAN.
-
#initialize(original:, normalized:, valid:, reason: nil, format: nil) ⇒ BankAccountResult
constructor
A new instance of BankAccountResult.
Methods inherited from Result
#invalid?, #to_s, #valid?, #value
Constructor Details
#initialize(original:, normalized:, valid:, reason: nil, format: nil) ⇒ BankAccountResult
Returns a new instance of BankAccountResult.
126 127 128 129 |
# File 'lib/israeli/result.rb', line 126 def initialize(original:, normalized:, valid:, reason: nil, format: nil) super(original: original, normalized: normalized, valid: valid, reason: reason) @format = format end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
123 124 125 |
# File 'lib/israeli/result.rb', line 123 def format @format end |
Instance Method Details
#domestic? ⇒ Boolean
Returns true if this is a domestic account.
132 133 134 |
# File 'lib/israeli/result.rb', line 132 def domestic? format == :domestic end |
#formatted(style: :domestic) ⇒ String?
Format the bank account.
145 146 147 148 149 |
# File 'lib/israeli/result.rb', line 145 def formatted(style: :domestic) return nil unless valid? Validators::BankAccount.format(@original, style: style) end |
#iban? ⇒ Boolean
Returns true if this is an IBAN.
137 138 139 |
# File 'lib/israeli/result.rb', line 137 def iban? format == :iban end |