Class: Freenom::Dns
- Inherits:
-
Object
- Object
- Freenom::Dns
- Defined in:
- lib/freenom/dns.rb,
lib/freenom/dns/version.rb
Constant Summary collapse
- VERSION =
'0.1.5'
Instance Attribute Summary collapse
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #create_record!(name:, type:, time_to_live:, target:) ⇒ Object
- #delete_record!(record) ⇒ Object
- #exist_record?(options = {}) ⇒ Boolean
-
#initialize(username:, password:, domain:) ⇒ Dns
constructor
A new instance of Dns.
- #records ⇒ Object
Constructor Details
#initialize(username:, password:, domain:) ⇒ Dns
Returns a new instance of Dns.
13 14 15 16 17 |
# File 'lib/freenom/dns.rb', line 13 def initialize(username:, password:, domain:) @username = username @password = password @domain = domain end |
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain.
11 12 13 |
# File 'lib/freenom/dns.rb', line 11 def domain @domain end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/freenom/dns.rb', line 11 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
11 12 13 |
# File 'lib/freenom/dns.rb', line 11 def username @username end |
Instance Method Details
#create_record!(name:, type:, time_to_live:, target:) ⇒ Object
28 29 30 31 32 |
# File 'lib/freenom/dns.rb', line 28 def create_record!(name:, type:, time_to_live:, target:) Freenom::Authenticator.new(username: @username, password: @password).run Freenom::DNSRecordCreator.new(domain: @domain) .run(name: name, type: type, time_to_live: time_to_live, target: target) end |
#delete_record!(record) ⇒ Object
34 35 36 37 |
# File 'lib/freenom/dns.rb', line 34 def delete_record!(record) Freenom::Authenticator.new(username: @username, password: @password).run Freenom::DNSRecordDeleter.new(domain: @domain).run(record: record) end |
#exist_record?(options = {}) ⇒ Boolean
24 25 26 |
# File 'lib/freenom/dns.rb', line 24 def exist_record?( = {}) records.any? { |record| record.match?() } end |
#records ⇒ Object
19 20 21 22 |
# File 'lib/freenom/dns.rb', line 19 def records Freenom::Authenticator.new(username: @username, password: @password).run Freenom::DNSRecordsFetcher.new(domain: @domain).run end |