module SimplerCommand::StringUtils
Simple Utilities for either using ActiveSupport methods, or falling back to equivalents.
Used only for generating Human-readable Strings, which should not be used for logic
Public Instance Methods
humanize(string)
click to toggle source
Converts a string to a human-readable string
# File lib/simpler_command/string_utils.rb, line 11 def humanize(string) attribute = string.tr(".", "_") if attribute.respond_to?(:humanize) attribute.humanize else attribute.tr("_", " ").capitalize end end
to_sentence(array)
click to toggle source
Attempt Array#to_sentence provided by ActiveSupport, or fall back to join
# File lib/simpler_command/string_utils.rb, line 21 def to_sentence(array) if array.respond_to?(:to_sentence) array.to_sentence else array.join(", ") end end