Class: String — Documentation by YARD 0.9.44

# Class: String

Inherits:
  Object
  - Object
  - String
  show all

Defined in:
  lib/unisec/utils.rb

## Instance Method Summary collapse

- #to_bool ⇒ TrueClass|FalseClass

  Convert a string to a boolean.

## Instance Method Details

### #to_bool ⇒ `TrueClass|FalseClass`

Convert a string to a boolean

#### Examples:

    "true".to_bool # => true

Returns:

- (`TrueClass|FalseClass`)

    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    # File 'lib/unisec/utils.rb', line 28

    def to_bool
      case to_s.chomp.downcase
      when 'true', 'yes', 'y', '1'
        true
      when 'false', 'no', 'n', '0'
        false
      else
        raise ArgumentError, "invalid value for Boolean: #{str.inspect}"
      end
    end