Class: DNSimple::Commands::ListRecords

Inherits:
DNSimple::Command show all
Defined in:
lib/dnsimple/commands/list_records.rb

Instance Method Summary collapse

Methods inherited from DNSimple::Command

#initialize, #say

Constructor Details

This class inherits a constructor from DNSimple::Command

Instance Method Details

#execute(args, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/dnsimple/commands/list_records.rb', line 6

def execute(args, options={})
  domain_name = args.shift

  records = Record.all(DNSimple::Domain.new(:name => domain_name))

  say "Found #{records.length} records for #{domain_name}"
  records.each do |record|
    extra = ["ttl:#{record.ttl}", "id:#{record.id}"]
    extra << "prio:#{record.prio}" if record.record_type == "MX"
    extra = "(#{extra.join(', ')})"
    say "\t#{record.name}.#{record.domain.name} (#{record.record_type})-> #{record.content} #{extra}"
  end
end