Class: Jcsv::RBForbidSubstrings

Inherits:
Filter
  • Object
show all
Defined in:
lib/constraints.rb

Overview

Instance Attribute Summary collapse

Attributes included from NextFilter

#last_filter, #next_filter

Instance Method Summary collapse

Methods included from NextFilter

#>>, #exec_next

Constructor Details

#initialize(substrings) ⇒ RBForbidSubstrings

Returns a new instance of RBForbidSubstrings.



61
62
63
64
# File 'lib/constraints.rb', line 61

def initialize(substrings)
  @substrings = substrings
  super()
end

Instance Attribute Details

#substringsObject (readonly)

Returns the value of attribute substrings.



59
60
61
# File 'lib/constraints.rb', line 59

def substrings
  @substrings
end

Instance Method Details

#execute(value, context) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/constraints.rb', line 66

def execute(value, context)
  validateInputNotNull(value, context)
  substrings.each do |sub|
    raise "Substring #{sub} found in #{value}:\n#{context}" if value.include?(sub)
  end
  exec_next(value, context)
end