Class: DNS::Monitor::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/dns/monitor/check.rb

Instance Method Summary collapse

Constructor Details

#initialize(domain, status, diff = {}) ⇒ Check

A “Check” is an encapsulated domain query result.



5
6
7
8
9
# File 'lib/dns/monitor/check.rb', line 5

def initialize(domain, status, diff={})
  @diff = diff
  @domain = domain
  @status = status
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/dns/monitor/check.rb', line 11

def changed?
  @status == :changed
end

#ok?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/dns/monitor/check.rb', line 15

def ok?
  @status == :ok
end

#statusObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/dns/monitor/check.rb', line 19

def status
  case @status
    when :ok
      { domain: @domain, ok: true }
    when :changed
      { domain: @domain, changes: @diff }
    else
      :error
  end
end

#to_sObject



30
31
32
# File 'lib/dns/monitor/check.rb', line 30

def to_s
  status.inspect
end