Skip to content

Commit

Permalink
Update unkown details to not add an instance variable
Browse files Browse the repository at this point in the history
  • Loading branch information
lauragilgz committed Jan 21, 2025
1 parent be3411e commit 965f52b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Object example:

```
#<CFONB::Details:0x0000
@AAA="UNKNOWN DETAIL INFO",
@LIB="MENSUEAUHTR12345",
@NPY="INTERNET SFR",
@RCN="OTHER REFERENCE PURPOSE",
Expand Down
2 changes: 1 addition & 1 deletion cfonb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = 'cfonb'
s.version = '1.1.1'
s.version = '1.2.0'
s.required_ruby_version = '>= 3.2'
s.summary = 'CFONB parser'
s.description = 'An easy to use CFONB format parser'
Expand Down
11 changes: 7 additions & 4 deletions lib/cfonb/operation_details/unknown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

module CFONB
module OperationDetails
class Unknown < Base
ATTRIBUTES = %i[unknown].freeze

class Unknown
def self.apply(details, line)
details.unknown ||= {}
unless details.instance_variable_defined?(:@unknown)
details.instance_variable_set(:@unknown, {})

details.class.attr_accessor :unknown
end

code = line.detail_code.gsub(' ', '_')

details.unknown[code] =
Expand Down
1 change: 1 addition & 0 deletions spec/cfonb/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'BBB' => 'INTERNETE BBB',
'CCC' => 'INTERNETI CCC',
'N_Y' => 'EXAMPLE WITH EMPTY SPACE',
'2\'C' => 'EXAMPLE WITH OTHER COMBINATIONS',
},
)

Expand Down
2 changes: 1 addition & 1 deletion spec/files/example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
0515589916200000EUR2 98765432100B1160519 CCCINTERNETI CCC
0515589916200000EUR2 98765432100B1160519
0515589916200000EUR2 98765432100B1160519 N YEXAMPLE WITH EMPTY SPACE

0515589916200000EUR2 98765432100B1160519 2'CEXAMPLE WITH OTHER COMBINATIONS
0415589916200000EUR2 98765432100B1160519 160519VIR SEPA DEMONSTRATION 0000000000000000000107}REFERENCE
0515589916200000EUR2 98765432100B1160519 NPYELEC ERDF

Expand Down

0 comments on commit 965f52b

Please sign in to comment.