Class: TortoiseLabs::DNS::Record

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

Overview

DNS record class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rhash) ⇒ Record

Returns a new instance of Record.



71
72
73
74
# File 'lib/tortoiselabs/dns.rb', line 71

def initialize(rhash)
  @id, @name, @content = rhash["id"], rhash["name"], rhash["content"]
  @prio, @ttl, @type = rhash["prio"], rhash["ttl"], rhash["type"]
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



68
69
70
# File 'lib/tortoiselabs/dns.rb', line 68

def content
  @content
end

#idObject (readonly)

Returns the value of attribute id.



68
69
70
# File 'lib/tortoiselabs/dns.rb', line 68

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



68
69
70
# File 'lib/tortoiselabs/dns.rb', line 68

def name
  @name
end

#prioObject (readonly)

Returns the value of attribute prio.



68
69
70
# File 'lib/tortoiselabs/dns.rb', line 68

def prio
  @prio
end

#ttlObject (readonly)

Returns the value of attribute ttl.



68
69
70
# File 'lib/tortoiselabs/dns.rb', line 68

def ttl
  @ttl
end

#typeObject (readonly)

Returns the value of attribute type.



68
69
70
# File 'lib/tortoiselabs/dns.rb', line 68

def type
  @type
end

#zoneidObject

Returns the value of attribute zoneid.



69
70
71
# File 'lib/tortoiselabs/dns.rb', line 69

def zoneid
  @zoneid
end

Instance Method Details

#deleteObject



82
83
84
85
# File 'lib/tortoiselabs/dns.rb', line 82

def delete
  resp = TortoiseLabs::Client.get("/dns/zone/#{@zoneid}/record/#{@id}/delete")
  Zone.new(JSON.parse(resp)["zone"])
end

#modify(new_content, subdomain = @name) ⇒ Object



76
77
78
79
80
# File 'lib/tortoiselabs/dns.rb', line 76

def modify(new_content, subdomain = @name)
  TortoiseLabs::Client.post("/dns/zone/#{@zoneid}/record/#{@id}",
      {:content => new_content, :subdomain => subdomain})
  Zone.list.values.select { |z| z.id == zoneid }[0]
end

#to_sObject



87
88
89
# File 'lib/tortoiselabs/dns.rb', line 87

def to_s
  "#{@type}:#{@name}"
end