Class: Kiba::Extend::Transforms::Cspace::FlagInvalidCharacters
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Cspace::FlagInvalidCharacters
- Defined in:
- lib/kiba/extend/transforms/cspace/flag_invalid_characters.rb
Instance Method Summary collapse
-
#initialize(check:, flag:) ⇒ FlagInvalidCharacters
constructor
A new instance of FlagInvalidCharacters.
-
#process(row) ⇒ Object
Constructor Details
#initialize(check:, flag:) ⇒ FlagInvalidCharacters
Returns a new instance of FlagInvalidCharacters.
8 9 10 11 |
# File 'lib/kiba/extend/transforms/cspace/flag_invalid_characters.rb', line 8 def initialize(check:, flag:) @check = check @flag = flag end |
Instance Method Details
#process(row) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kiba/extend/transforms/cspace/flag_invalid_characters.rb', line 14 def process(row) val = row.fetch(@check, nil) if val.blank? row[@flag] = nil else # rubocop:todo Layout/LineLength val = val.unicode_normalized?(:nfkc) ? val : val.unicode_normalize(:nfkc) # rubocop:enable Layout/LineLength Cspace.shady_characters.each { |k, v| val = val.gsub(k, v) } norm = ActiveSupport::Inflector.transliterate(val, "%INVCHAR%") row[@flag] = norm.include?("%INVCHAR%") ? norm : nil end row end |