class See5::Rule
Attributes
classification[R]
conditions[R]
confidence[R]
rule_info[R]
Public Class Methods
from_h(h)
click to toggle source
# File lib/see5/rule.rb, line 27 def self.from_h(h) new(h[:rule_info], h[:conditions], { classification: h[:classification], confidence: h[:confidence] }) end
new(rule_info, conditions, class_info)
click to toggle source
# File lib/see5/rule.rb, line 7 def initialize(rule_info, conditions, class_info) @rule_info = rule_info @conditions = conditions @classification = class_info[:classification] @confidence = class_info[:confidence] end
Public Instance Methods
match?(data)
click to toggle source
# File lib/see5/rule.rb, line 14 def match?(data) conditions .map { |attr, val| data[attr] == val } .all? { |matched| matched == true } end
to_h()
click to toggle source
# File lib/see5/rule.rb, line 20 def to_h { rule_info: rule_info, conditions: conditions, classification: classification, confidence: confidence } end
to_s()
click to toggle source
# File lib/see5/rule.rb, line 34 def to_s [ "See5::Rule", "@classification=#{classification}", "@conditions=#{conditions}" ] .join(", ") .yield_self { |s| "#<#{s}>" } end