Class: CategoricalPredicate
- Inherits:
-
Object
- Object
- CategoricalPredicate
- Defined in:
- lib/categorical_predicate.rb
Constant Summary collapse
- IS_IN =
'isIn'
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Instance Method Summary collapse
-
#initialize(pred_xml) ⇒ CategoricalPredicate
constructor
A new instance of CategoricalPredicate.
- #true?(features) ⇒ Boolean
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
#field ⇒ Object (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
13 14 15 |
# File 'lib/categorical_predicate.rb', line 13 def true?(features) @array.include? features[@field] if @operator == IS_IN end |