Class: ValueDomainDdns::Core
- Inherits:
-
Object
- Object
- ValueDomainDdns::Core
- Defined in:
- lib/value-domain-ddns/core.rb
Instance Method Summary collapse
- #get_ip ⇒ Object
-
#initialize(config) ⇒ Core
constructor
A new instance of Core.
- #submit_params ⇒ Object
- #sync ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(config) ⇒ Core
Returns a new instance of Core.
7 8 9 |
# File 'lib/value-domain-ddns/core.rb', line 7 def initialize(config) @config = config end |
Instance Method Details
#get_ip ⇒ Object
15 16 17 |
# File 'lib/value-domain-ddns/core.rb', line 15 def get_ip() open(ValueDomainDdns::GET_IP_URL).read end |
#submit_params ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/value-domain-ddns/core.rb', line 19 def submit_params { 'd' => @config[:domain], 'p' => @config[:password], 'h' => @config[:hostname], 'i' => @config[:ip] } end |
#sync ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/value-domain-ddns/core.rb', line 28 def sync() query_string = submit_params.map { |k, v| URI.encode(k.to_s) + '=' + URI.encode(v.to_s) }.join('&') submit_url = ValueDomainDdns::SUBMIT_BASE_URL + '?' + query_string open(URI.parse(submit_url)).read end |
#validate ⇒ Object
11 12 13 |
# File 'lib/value-domain-ddns/core.rb', line 11 def validate !!@config[:domain] && !!@config[:password] && !!@config[:hostname] end |