module Fog::Proxmox::ControllerHelper

module ControllerHelper mixins

Constants

CONTROLLERS

Public Class Methods

collect_controllers(attributes) click to toggle source
# File lib/fog/proxmox/helpers/controller_helper.rb, line 56
def self.collect_controllers(attributes)
  controllers = {}
  CONTROLLERS.each { |controller| controllers.merge!(select(attributes, controller)) }
  controllers
end
extract(name, controller_value) click to toggle source
# File lib/fog/proxmox/helpers/controller_helper.rb, line 26
def self.extract(name, controller_value)
  values = controller_value.scan(/#{name}=(\w+)/)
  name_value = values.first if values
  name_value&.first
end
extract_index(name, key) click to toggle source
# File lib/fog/proxmox/helpers/controller_helper.rb, line 32
def self.extract_index(name, key)
  idx_a = key.to_s.scan(/#{name}(\d+)/).first
  idx_a.first.to_i if idx_a
end
last_index(name, values) click to toggle source
# File lib/fog/proxmox/helpers/controller_helper.rb, line 41
def self.last_index(name, values)
  return -1 if values.empty?
  indexes = []
  values.each do |value|
    index = extract_index(name, value)
    indexes.push(index) if index
  end
  indexes.sort
  indexes.empty? ? -1 : indexes.last
end
select(hash,name) click to toggle source
# File lib/fog/proxmox/helpers/controller_helper.rb, line 52
def self.select(hash,name)
  hash.select { |key| valid?(name, key.to_s) }
end
valid?(name, key) click to toggle source
# File lib/fog/proxmox/helpers/controller_helper.rb, line 37
def self.valid?(name, key)
  key.to_s.match(/^#{name}(\d*)$/)
end