Class: CategoricalPredicate

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

Constant Summary collapse

IS_IN =
'isIn'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pred_xml) ⇒ CategoricalPredicate

Returns a new instance of CategoricalPredicate.



7
8
9
10
11
# File 'lib/categorical_predicate.rb', line 7

def initialize(pred_xml)
  @field = pred_xml.xpath('@field').to_s.to_sym
  @array = pred_xml.xpath('Array/text()').to_s.tr('"', '').split('   ')
  @operator = pred_xml.xpath('@booleanOperator').to_s
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



5
6
7
# File 'lib/categorical_predicate.rb', line 5

def field
  @field
end

Instance Method Details

#true?(features) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/categorical_predicate.rb', line 13

def true?(features)
  @array.include? features[@field] if @operator == IS_IN
end