Class: Jcsv::RBStrConstraints

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

Overview

Instance Attribute Summary

Attributes included from NextFilter

#last_filter, #next_filter

Instance Method Summary collapse

Methods included from NextFilter

#>>, #exec_next

Constructor Details

#initialize(function, *args, check: true) ⇒ RBStrConstraints

Returns a new instance of RBStrConstraints.



141
142
143
144
145
146
# File 'lib/constraints.rb', line 141

def initialize(function, *args, check: true)
  @function = function
  @args = args
  @check = check
  super()
end

Instance Method Details

#execute(value, context) ⇒ Object



148
149
150
151
152
153
# File 'lib/constraints.rb', line 148

def execute(value, context)
  truth = value.send(@function, *(@args))
  raise "Constraint #{@function} with value #{value} is #{truth}:\n#{context}" if
    truth == @check
  exec_next(value, context)
end