Class: MonoVM::Whois::Availability::Verdict
- Inherits:
-
Object
- Object
- MonoVM::Whois::Availability::Verdict
- Defined in:
- lib/monovm/whois/availability/verdict.rb
Overview
The outcome of analysing one response.
This is the central design decision. With a boolean-only
isAvailable(), "this domain is registered" and "the
server would not tell me" collapse into the same false — and, worse, a
response that carries no verdict at all falls through the detector's
heuristics and comes back true. A rate-limited registry then reports
every registered domain as free to register.
Here #status has four values and :unknown is a real answer that is
never promoted to :available. #rule and #trace record why, which
is what makes a surprising classification debuggable.
Constant Summary collapse
- STATUSES =
%i[available registered premium unknown].freeze
Instance Attribute Summary collapse
-
#evidence ⇒ Object
readonly
Returns the value of attribute evidence.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #available? ⇒ Boolean
-
#conclusive? ⇒ Boolean
True when the verdict says something actionable about the domain.
- #hash ⇒ Object
-
#initialize(status:, rule: nil, reason: nil, evidence: nil, trace: nil) ⇒ Verdict
constructor
A new instance of Verdict.
- #inspect ⇒ Object
- #premium? ⇒ Boolean
- #registered? ⇒ Boolean
- #to_h ⇒ Object
-
#unknown? ⇒ Boolean
True when no rule could reach a conclusion, or when the server refused to answer.
-
#with_trace(trace) ⇒ Object
Return a copy carrying
trace.
Constructor Details
#initialize(status:, rule: nil, reason: nil, evidence: nil, trace: nil) ⇒ Verdict
Returns a new instance of Verdict.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/monovm/whois/availability/verdict.rb', line 36 def initialize(status:, rule: nil, reason: nil, evidence: nil, trace: nil) raise ArgumentError, "unknown verdict status #{status.inspect}" unless STATUSES.include?(status) @status = status @rule = rule @reason = reason @evidence = evidence @trace = (trace || []).freeze freeze end |
Instance Attribute Details
#evidence ⇒ Object (readonly)
Returns the value of attribute evidence.
21 22 23 |
# File 'lib/monovm/whois/availability/verdict.rb', line 21 def evidence @evidence end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
21 22 23 |
# File 'lib/monovm/whois/availability/verdict.rb', line 21 def reason @reason end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
21 22 23 |
# File 'lib/monovm/whois/availability/verdict.rb', line 21 def rule @rule end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
21 22 23 |
# File 'lib/monovm/whois/availability/verdict.rb', line 21 def status @status end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
21 22 23 |
# File 'lib/monovm/whois/availability/verdict.rb', line 21 def trace @trace end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
85 86 87 |
# File 'lib/monovm/whois/availability/verdict.rb', line 85 def ==(other) other.is_a?(Verdict) && other.status == status && other.rule == rule end |
#available? ⇒ Boolean
47 48 49 |
# File 'lib/monovm/whois/availability/verdict.rb', line 47 def available? status == :available end |
#conclusive? ⇒ Boolean
True when the verdict says something actionable about the domain.
66 67 68 |
# File 'lib/monovm/whois/availability/verdict.rb', line 66 def conclusive? !unknown? end |
#hash ⇒ Object
90 91 92 |
# File 'lib/monovm/whois/availability/verdict.rb', line 90 def hash [self.class, status, rule].hash end |
#inspect ⇒ Object
94 95 96 |
# File 'lib/monovm/whois/availability/verdict.rb', line 94 def inspect "#<#{self.class.name} #{status}#{" by #{rule}" if rule}>" end |
#premium? ⇒ Boolean
55 56 57 |
# File 'lib/monovm/whois/availability/verdict.rb', line 55 def premium? status == :premium end |
#registered? ⇒ Boolean
51 52 53 |
# File 'lib/monovm/whois/availability/verdict.rb', line 51 def registered? status == :registered end |
#to_h ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/monovm/whois/availability/verdict.rb', line 76 def to_h { status: status, rule: rule, reason: reason, evidence: evidence } end |
#unknown? ⇒ Boolean
True when no rule could reach a conclusion, or when the server refused to answer. Callers must treat this as "ask again later", never as free.
61 62 63 |
# File 'lib/monovm/whois/availability/verdict.rb', line 61 def unknown? status == :unknown end |
#with_trace(trace) ⇒ Object
Return a copy carrying trace. Rules build verdicts without knowing the
trace; the analyzer attaches it once the chain finishes.
72 73 74 |
# File 'lib/monovm/whois/availability/verdict.rb', line 72 def with_trace(trace) self.class.new(status: status, rule: rule, reason: reason, evidence: evidence, trace: trace) end |