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 55 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 25 def self.extract(name, controller_value) matches = controller_value.match(/[,]{0,1}#{name}[=]{1}(?<name_value>[\w\/]+)/) matches ? matches[:name_value] : matches end
extract_index(name, key)
click to toggle source
# File lib/fog/proxmox/helpers/controller_helper.rb, line 30 def self.extract_index(name, key) matches = key.to_s.match(/#{name}(?<index>\d+)/) index = matches ? matches[:index] : matches index ? index.to_i : -1 end
last_index(name, values)
click to toggle source
# File lib/fog/proxmox/helpers/controller_helper.rb, line 40 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 51 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 36 def self.valid?(name, key) key.to_s.match(/^#{name}(\d*)$/) end