Class: MonoVM::Whois::Availability::Analyzer
- Inherits:
-
Object
- Object
- MonoVM::Whois::Availability::Analyzer
- Defined in:
- lib/monovm/whois/availability/analyzer.rb
Overview
Runs a response through the rule chain and returns the first verdict.
The analyzer holds no detection logic of its own — it walks the RuleSet, stops at the first rule that answers, and records what every rule said on the way. That trace is what turns "why does this say available?" from an afternoon of guessing into one call to #explain.
When no rule answers, the result is :unknown. That is the other half of the
correctness argument: the default is "I do not know", not "it is free".
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #analyze(response:, tld: nil, definition: nil) ⇒ Verdict
-
#explain(response:, tld: nil, definition: nil) ⇒ Hash
Analyse and return the verdict together with every rule's outcome, for debugging a surprising classification.
-
#initialize(rules: nil) ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
#initialize(rules: nil) ⇒ Analyzer
Returns a new instance of Analyzer.
22 23 24 |
# File 'lib/monovm/whois/availability/analyzer.rb', line 22 def initialize(rules: nil) @rules = rules || RuleSet.default end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
20 21 22 |
# File 'lib/monovm/whois/availability/analyzer.rb', line 20 def rules @rules end |
Instance Method Details
#analyze(response:, tld: nil, definition: nil) ⇒ Verdict
30 31 32 33 |
# File 'lib/monovm/whois/availability/analyzer.rb', line 30 def analyze(response:, tld: nil, definition: nil) context = Context.new(response: response, tld: tld, definition: definition) run(context) end |
#explain(response:, tld: nil, definition: nil) ⇒ Hash
Analyse and return the verdict together with every rule's outcome, for debugging a surprising classification.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/monovm/whois/availability/analyzer.rb', line 39 def explain(response:, tld: nil, definition: nil) context = Context.new(response: response, tld: tld, definition: definition) verdict = run(context) { status: verdict.status, decided_by: verdict.rule, reason: verdict.reason, evidence: verdict.evidence, trace: verdict.trace, tld: tld, response_length: context.length, response_preview: context.preview } end |