Class: FuzzyWhere::PredicateMembershipDegree
- Inherits:
-
Object
- Object
- FuzzyWhere::PredicateMembershipDegree
- Defined in:
- lib/fuzzy_where/predicate_membership_degree.rb
Overview
Class to determine the membership degree calculation for a given column and add the select conditions
Instance Attribute Summary collapse
-
#calculation ⇒ Object
readonly
Returns the value of attribute calculation.
Instance Method Summary collapse
-
#initialize(table, column, fuzzy_predicate) ⇒ PredicateMembershipDegree
constructor
New MembershipDegree intance.
-
#membership_function ⇒ String
Take instance attributes and return a calculations for them Based on fuzzy set trapezium function.
Constructor Details
#initialize(table, column, fuzzy_predicate) ⇒ PredicateMembershipDegree
New MembershipDegree intance
14 15 16 17 18 |
# File 'lib/fuzzy_where/predicate_membership_degree.rb', line 14 def initialize(table, column, fuzzy_predicate) @table = table @column = column @fuzzy_predicate = fuzzy_predicate end |
Instance Attribute Details
#calculation ⇒ Object (readonly)
Returns the value of attribute calculation.
8 9 10 |
# File 'lib/fuzzy_where/predicate_membership_degree.rb', line 8 def calculation @calculation end |
Instance Method Details
#membership_function ⇒ String
Take instance attributes and return a calculations for them Based on fuzzy set trapezium function
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fuzzy_where/predicate_membership_degree.rb', line 23 def membership_function min = @fuzzy_predicate[:min] max = @fuzzy_predicate[:max] @calculation = if !min || min == 'infinite'.freeze decreasing elsif !max || max == 'infinite'.freeze increasing else unimodal end @calculation end |