class CategoricalPredicate
Constants
- IS_IN
Attributes
field[R]
Public Class Methods
new(pred_xml)
click to toggle source
# File lib/categorical_predicate.rb, line 7 def initialize(pred_xml) attributes = pred_xml.attributes @field = attributes['field'].value.to_sym @array = pred_xml.children[0].content.tr('"', '').split(' ') @operator = attributes['booleanOperator'].value end
Public Instance Methods
format_boolean(features)
click to toggle source
# File lib/categorical_predicate.rb, line 19 def format_boolean(features) features[@field] = 'f' if features[@field] == false features[@field] = 't' if features[@field] == true end
true?(features)
click to toggle source
# File lib/categorical_predicate.rb, line 14 def true?(features) format_boolean(features) @array.include? features[@field] if @operator == IS_IN end