Module: Fog::Proxmox::String

Defined in:
lib/fog/proxmox/string.rb

Overview

module String mixins

Class Method Summary collapse

Class Method Details

.to_boolean(text) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
# File 'lib/fog/proxmox/string.rb', line 24

def self.to_boolean(text)
  return true if text == true   || text =~ (/(true|t|yes|y|1)$/i)
  return false if text == false  || text.empty? || text =~ (/(false|f|no|n|0)$/i)
  raise ArgumentError.new("invalid value for Boolean: \"#{text}\"")
end