Class: Updateafraid::AfraidAccount
- Inherits:
-
Object
- Object
- Updateafraid::AfraidAccount
- Defined in:
- lib/updateafraid.rb
Instance Attribute Summary collapse
-
#domains ⇒ Object
Returns the value of attribute domains.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #getdyndns ⇒ Object
-
#initialize(username, password) ⇒ AfraidAccount
constructor
A new instance of AfraidAccount.
- #print_domains ⇒ Object
- #update(domain) ⇒ Object
- #update_all ⇒ Object
Constructor Details
#initialize(username, password) ⇒ AfraidAccount
Returns a new instance of AfraidAccount.
6 7 8 9 |
# File 'lib/updateafraid.rb', line 6 def initialize(username, password) @username, @password = username, password @domains = self.getdyndns end |
Instance Attribute Details
#domains ⇒ Object
Returns the value of attribute domains.
5 6 7 |
# File 'lib/updateafraid.rb', line 5 def domains @domains end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/updateafraid.rb', line 5 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/updateafraid.rb', line 5 def username @username end |
Instance Method Details
#getdyndns ⇒ Object
11 12 13 14 15 16 |
# File 'lib/updateafraid.rb', line 11 def getdyndns sha1 = Digest::SHA1.hexdigest(@username+'|'+@password) xml = open("http://freedns.afraid.org/api/" + "?action=getdyndns"+"&sha="+sha1+"&style=xml", "User-Agent" => 'updateafraid.rb').read return Domain.parse(xml) end |
#print_domains ⇒ Object
37 38 39 40 |
# File 'lib/updateafraid.rb', line 37 def print_domains puts "You have " + self.domains.size.to_s + " domains:" self.domains.each do |d| puts d.host + "\t(" + d.address + ")" end end |
#update(domain) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/updateafraid.rb', line 26 def update(domain) o = false self.domains.each { |d| if d.host == domain o = d.update break end } return o end |
#update_all ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/updateafraid.rb', line 18 def update_all responses = Array.new @domains.each do |domain| responses.push domain.host + " - " + domain.update end return responses end |