Sha256: 26f52e8ec9027b7744960f1b7307b37aecfeb309c816ccee0488da1ae6b213f5
Contents?: true
Size: 646 Bytes
Versions: 2
Compression:
Stored size: 646 Bytes
Contents
require 'caruby/active_support/inflector' class String # @param [Numeric] quantity the amount qualifier # @return this String qualified by a plural if the quantity is not 1 # @example # "rose".quantify(3) #=> "roses" # "rose".quantify(1 #=> "rose" def quantify(quantity) raise ArgumentError.new("Missing quantity argument") if quantity.nil? "#{quantity} #{quantity == 1 ? self : pluralize}" end # @return this String with the first letter capitalized and other letters preserved. # @example # "rosesAreRed".capitalize_first #=> "RosesAreRed" def capitalize_first sub(/(?:^)(.)/) { $1.upcase } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
caruby-core-1.4.2 | lib/caruby/util/inflector.rb |
caruby-core-1.4.1 | lib/caruby/util/inflector.rb |