Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudfront/utils/string.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/cloudfront/utils/string.rb', line 8

def blank?
  self.strip.empty?
end

#to_boolObject

Raises:

  • (ArgumentError)


2
3
4
5
6
# File 'lib/cloudfront/utils/string.rb', line 2

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