class Scoruby::Predicates::SimpleSetPredicate
Constants
- IS_IN
Attributes
array[R]
field[R]
Public Class Methods
new(pred_xml)
click to toggle source
# File lib/scoruby/predicates/simple_set_predicate.rb, line 10 def initialize(pred_xml) attributes = pred_xml.attributes @field = attributes['field'].value.to_sym @array = single_or_quoted_words(pred_xml.children[0].content) @operator = attributes['booleanOperator'].value end
Public Instance Methods
missing?(features)
click to toggle source
# File lib/scoruby/predicates/simple_set_predicate.rb, line 21 def missing?(features) !features.keys.include?(@field) end
true?(features)
click to toggle source
# File lib/scoruby/predicates/simple_set_predicate.rb, line 17 def true?(features) @array.include? features[@field] if @operator == IS_IN end
Private Instance Methods
single_or_quoted_words(string)
click to toggle source
# File lib/scoruby/predicates/simple_set_predicate.rb, line 27 def single_or_quoted_words(string) string.split(/\s(?=(?:[^"]|"[^"]*")*$)/) .reject(&:empty?) .map { |w| w.tr('"', '') } end