Module: OnlyofficeDigitaloceanWrapper::IpGetters

Included in:
DigitalOceanWrapper
Defined in:
lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/ip_getters.rb

Overview

Get methods for IP

Instance Method Summary collapse

Instance Method Details

#droplet_ip(droplet, network_type = 'public') ⇒ String?

Get ip of droplet

Parameters:

  • droplet (DropletKit)

    to get ip

  • network_type (String) (defaults to: 'public')

    to get ip

Returns:

  • (String, nil)

    ip of droplet or ‘nil` if there is no such network



10
11
12
13
14
15
16
# File 'lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/ip_getters.rb', line 10

def droplet_ip(droplet, network_type = 'public')
  networks = droplet.networks.to_a.first
  specific_network = networks.find { |net| net.type == network_type }
  return nil unless specific_network

  specific_network.ip_address
end

#public_ip(droplet) ⇒ String?

Get public ip of droplet

Parameters:

  • droplet (DropletKit)

    to get ip

Returns:

  • (String, nil)

    public ip or ‘nil` if there is no such network



21
22
23
# File 'lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/ip_getters.rb', line 21

def public_ip(droplet)
  droplet_ip(droplet, 'public')
end