Class: Bmc

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/bmc.rb

Overview

General Utilily class

Class Method Summary collapse

Class Method Details

.boolean_to_symbol(value) ⇒ Object



19
20
21
22
23
# File 'lib/puppet_x/bmc.rb', line 19

def self.boolean_to_symbol(value)
  return :true if [true, 'true', :true].include? value
  return :false if [false, 'false', :false].include? value
  raise "Expected symbol 'boolean' parameter, got '#{value}'"
end

.s_to_boolean(value) ⇒ Object



13
14
15
16
17
# File 'lib/puppet_x/bmc.rb', line 13

def self.s_to_boolean(value)
  return true if 'true'.casecmp(value).zero?
  return false if 'false'.casecmp(value).zero?
  raise "Expected string 'boolean' parameter, got '#{value}'"
end

.symbol_to_boolean(value) ⇒ Object



25
26
27
28
29
# File 'lib/puppet_x/bmc.rb', line 25

def self.symbol_to_boolean(value)
  return true if :true.eql? value
  return false if :false.eql? value
  raise "Expected symbol parameter, got '#{value}'"
end

.values_to_boolean(input_array, munchable_elements = []) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/puppet_x/bmc.rb', line 3

def self.values_to_boolean(input_array, munchable_elements = [])
  input_array.each_with_index.map do |value, index|
    if munchable_elements.include?(index)
      s_to_boolean(value)
    else
      value
    end
  end
end