class String
Public Instance Methods
pluralize()
click to toggle source
# File lib/matrack/utility.rb, line 23 def pluralize self + "s" unless self.end_with? "s" end
titleize()
click to toggle source
# File lib/matrack/utility.rb, line 19 def titleize split.map!(&:capitalize).join(" ") end
to_b()
click to toggle source
# File lib/matrack/utility.rb, line 13 def to_b return true if !self.nil? && (self == true || downcase == "true") return false if self.nil? || downcase == "false" || self == false false end
to_camel_case()
click to toggle source
# File lib/matrack/utility.rb, line 8 def to_camel_case return self if self !~ /_/ && self =~ /[A-Z]+.*/ split("_").map(&:capitalize).join end
to_snake_case()
click to toggle source
# File lib/matrack/utility.rb, line 2 def to_snake_case gsub("::", "/"). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase end