Class: Puppet::Settings::ValueTranslator

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/settings/value_translator.rb

Overview

Convert arguments into booleans, integers, or whatever.

Instance Method Summary collapse

Instance Method Details

#[](value) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/puppet/settings/value_translator.rb', line 3

def [](value)
  # Handle different data types correctly
  return case value
    when /^false$/i; false
    when /^true$/i; true
    when /^\d+$/i; Integer(value)
    when true; true
    when false; false
    else
      value.gsub(/^["']|["']$/,'').sub(/\s+$/, '')
  end
end