module VerboseTruth
#¶ ↑
require 'verbose_truth/version/version.rb'
#¶ ↑
Constants
- VERSION
#¶ ↑
VerboseTruth::VERSION
¶ ↑#¶ ↑
Public Class Methods
verbose_truth(i, append_dot = true)
click to toggle source
#¶ ↑
VerboseTruth.verbose_truth
¶ ↑
With this method we can convert “true” and “false” into “Yes” and “No”, which allows us to use well-formulated english sentences. For now we include the '.' character all the time.
Specific usage examples for this method:
verbose_truth(true) verbose_truth @traditional
#¶ ↑
# File lib/verbose_truth/verbose_truth.rb, line 20 def self.verbose_truth(i, append_dot = true) i = i.to_s case append_dot when :no_dot append_dot = false end case i when 'true','t','yes','ja','y','j' # nil i = 'Yes.' when 'false','f','no','nein','n' i = 'No.' else # Default since as of Oct 2014. Also includes "none" and "". i = 'No.' end # ======================================================================= # # Offer a no-dot variant as well. # ======================================================================= # unless append_dot i.chop! if i.end_with? '.' end return i end