class String
def self.random(length = 100)
def self.random(length = 100) (0...length).map { ("a".."z").to_a[rand(26)] }.join end
def ends_with?(suffix)
def ends_with?(suffix) suffix = suffix.to_s self[-suffix.length, suffix.length] == suffix end unless defined? ends_with?
def lower_camelcase
def lower_camelcase str = dup str.gsub!(/\/(.?)/) { "::#{$1.upcase}" } str.gsub!(/(?:_+|-+)([a-z])/) { $1.upcase } str.gsub!(/(\A|\s)([A-Z])/) { $1 + $2.downcase } str end
def map_soap_response
def map_soap_response return DateTime.parse(self) if Savon::SOAP::DateTimeRegexp === self return true if self.strip.downcase == "true" return false if self.strip.downcase == "false" self end
def snakecase
def snakecase str = dup str.gsub! /::/, '/' str.gsub! /([A-Z]+)([A-Z][a-z])/, '\1_\2' str.gsub! /([a-z\d])([A-Z])/, '\1_\2' str.tr! ".", "_" str.tr! "-", "_" str.downcase! str end
def starts_with?(prefix)
def starts_with?(prefix) prefix = prefix.to_s self[0, prefix.length] == prefix end unless defined? starts_with?
def strip_namespace
def strip_namespace split(":").last end
def to_soap_key
def to_soap_key self[-1, 1] == "!" ? chop : self end
def to_soap_value
def to_soap_value CGI.escapeHTML self end
def to_soap_value!
def to_soap_value! self end