Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class StringBoolean
- class << self
- TRUE = "1".freeze
- FALSE = "0".freeze
- TRUTHY = ["1", "t", "y", "true", "yes"].freeze
- FALSEY = ["0", "f", "n", "false", "no", ""].freeze
- def true
- TRUE
- end
- def false
- FALSE
- end
- def truthy?(value)
- TRUTHY.include?(value.to_s.downcase)
- end
- def falsey?(value)
- FALSEY.include?(value.to_s.downcase)
- end
- end
- end
Add Comment
Please, Sign In to add comment