Class: Ryo::Plugin::DNS
- Inherits:
-
Object
- Object
- Ryo::Plugin::DNS
- Defined in:
- lib/ryo/plugin/dns.rb
Constant Summary collapse
- TYPES =
%w(A AAAA CNAME MX NS SOA TXT).freeze
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
Class Method Summary collapse
Instance Method Summary collapse
- #dig(type) ⇒ Object
- #discover ⇒ Object
- #endpoint ⇒ Object
- #fetch_body(params) ⇒ Object
-
#initialize(domain) ⇒ DNS
constructor
A new instance of DNS.
Constructor Details
#initialize(domain) ⇒ DNS
Returns a new instance of DNS.
9 10 11 |
# File 'lib/ryo/plugin/dns.rb', line 9 def initialize(domain) @domain = domain end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
8 9 10 |
# File 'lib/ryo/plugin/dns.rb', line 8 def domain @domain end |
Class Method Details
.discover(domain) ⇒ Object
36 37 38 |
# File 'lib/ryo/plugin/dns.rb', line 36 def self.discover(domain) new(domain).discover end |
Instance Method Details
#dig(type) ⇒ Object
22 23 24 25 26 |
# File 'lib/ryo/plugin/dns.rb', line 22 def dig(type) params = { name: domain, type: type } body = fetch_body(params) JSON.parse(body) end |
#discover ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/ryo/plugin/dns.rb', line 28 def discover h = {} TYPES.each do |type| h[type] = dig(type) end h end |
#endpoint ⇒ Object
13 14 15 |
# File 'lib/ryo/plugin/dns.rb', line 13 def endpoint "https://dns.google.com/resolve" end |