Class: String

Inherits:
Object
  • Object
show all
Extended by:
Mugatu::AttributeType
Defined in:
lib/mugatu/types/string.rb

Constant Summary collapse

TRUTHY =
['t', 'true', 'on', 'y', 'yes', '1'].freeze
FALSY =
['f', 'false', 'off', 'n', 'no', '0'].freeze

Instance Method Summary collapse

Methods included from Mugatu::AttributeType

cast, get_cast_with, raise_cast_error, set_cast_with

Instance Method Details

#to_bObject



9
10
11
12
13
14
15
16
# File 'lib/mugatu/types/string.rb', line 9

def to_b
  value = downcase

  return true  if TRUTHY.include?(value)
  return false if FALSY.include?(value)

  self.class.raise_cast_error(self)
end