Class: SaltParser::Swift::TransactionInfo
- Inherits:
-
Object
- Object
- SaltParser::Swift::TransactionInfo
- Defined in:
- lib/swift/transaction_info.rb
Instance Attribute Summary collapse
-
#account_holder ⇒ Object
readonly
Returns the value of attribute account_holder.
-
#account_number ⇒ Object
readonly
Returns the value of attribute account_number.
-
#bank_code ⇒ Object
readonly
Returns the value of attribute bank_code.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#not_implemented_fields ⇒ Object
readonly
Returns the value of attribute not_implemented_fields.
-
#prima_nota ⇒ Object
readonly
Returns the value of attribute prima_nota.
-
#text_key_extension ⇒ Object
readonly
Returns the value of attribute text_key_extension.
-
#transaction_description ⇒ Object
readonly
Returns the value of attribute transaction_description.
Instance Method Summary collapse
-
#initialize(options) ⇒ TransactionInfo
constructor
A new instance of TransactionInfo.
- #to_hash ⇒ Object
Constructor Details
#initialize(options) ⇒ TransactionInfo
Returns a new instance of TransactionInfo.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/swift/transaction_info.rb', line 8 def initialize() match_data = [:content].match(/^(?<code>\d{3})(?<sub_fields>(?<seperator>.).*)$/) if match_data @code = match_data[:code].to_i details, account_holder = [], [] if seperator = match_data[:seperator] sub_fields = match_data[:sub_fields].scan(/#{Regexp.escape(seperator)}(\d{2})([^#{Regexp.escape(seperator)}]*)/) sub_fields.each do |(code, content)| case code.to_i when 0 @transaction_description = content when 10 @prima_nota = content when 20..29, 60..63 details << content when 30 @bank_code = content when 31 @account_number = content when 32..33 account_holder << content when 34 @text_key_extension = content else @not_implemented_fields ||= [] @not_implemented_fields << [code, content] end end end @details = details.join("\n") @account_holder = account_holder.join("\n") else @details = [:content] end end |
Instance Attribute Details
#account_holder ⇒ Object (readonly)
Returns the value of attribute account_holder.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def account_holder @account_holder end |
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def account_number @account_number end |
#bank_code ⇒ Object (readonly)
Returns the value of attribute bank_code.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def bank_code @bank_code end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def code @code end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def details @details end |
#not_implemented_fields ⇒ Object (readonly)
Returns the value of attribute not_implemented_fields.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def not_implemented_fields @not_implemented_fields end |
#prima_nota ⇒ Object (readonly)
Returns the value of attribute prima_nota.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def prima_nota @prima_nota end |
#text_key_extension ⇒ Object (readonly)
Returns the value of attribute text_key_extension.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def text_key_extension @text_key_extension end |
#transaction_description ⇒ Object (readonly)
Returns the value of attribute transaction_description.
4 5 6 |
# File 'lib/swift/transaction_info.rb', line 4 def transaction_description @transaction_description end |
Instance Method Details
#to_hash ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/swift/transaction_info.rb', line 47 def to_hash { :code => code, :transaction_description => transaction_description, :prima_nota => prima_nota, :details => details, :bank_code => bank_code, :account_number => account_number, :account_holder => account_holder, :text_key_extension => text_key_extension, :not_implemented_fields => not_implemented_fields } end |