Class: DoSnapshot::Adapter::Abstract

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/do_snapshot/adapter/abstract.rb

Overview

API for CLI commands Operating with Digital Ocean.

Direct Known Subclasses

DropletKit

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#logger, #mailer

Constructor Details

#initialize(options = {}) ⇒ Abstract

Returns a new instance of Abstract.



15
16
17
18
19
20
21
# File 'lib/do_snapshot/adapter/abstract.rb', line 15

def initialize(options = {})
  check_keys
  set_id
  options.each_pair do |key, option|
    send("#{key}=", option)
  end
end

Instance Attribute Details

#delayObject

Returns the value of attribute delay.



12
13
14
# File 'lib/do_snapshot/adapter/abstract.rb', line 12

def delay
  @delay
end

#stop_by=(value) ⇒ Object

Sets the attribute stop_by

Parameters:

  • value

    the value to set the attribute stop_by to.



13
14
15
# File 'lib/do_snapshot/adapter/abstract.rb', line 13

def stop_by=(value)
  @stop_by = value
end

#timeoutObject

Returns the value of attribute timeout.



12
13
14
# File 'lib/do_snapshot/adapter/abstract.rb', line 12

def timeout
  @timeout
end

Instance Method Details

#start_droplet(id) ⇒ Object

Power On request for Droplet



25
26
27
28
29
30
31
32
# File 'lib/do_snapshot/adapter/abstract.rb', line 25

def start_droplet(id)
  # noinspection RubyResolve
  instance = droplet(id)

  return power_on(id) if instance.respond_to?(:status) && !instance.status.include?('active')

  logger.error "Droplet #{id} is still running. Skipping."
end