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
- #format_boolean(features) ⇒ Object
-
#initialize(pred_xml) ⇒ CategoricalPredicate
constructor
A new instance of CategoricalPredicate.
- #true?(features) ⇒ Boolean
Constructor Details
#initialize(pred_xml) ⇒ CategoricalPredicate
7 8 9 10 11 12 |
# 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 |
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
#format_boolean(features) ⇒ Object
19 20 21 22 |
# 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) ⇒ Boolean
14 15 16 17 |
# File 'lib/categorical_predicate.rb', line 14 def true?(features) format_boolean(features) @array.include? features[@field] if @operator == IS_IN end |