Sha256: 17ec824741b8b471cef1fd2e82c16fe8b28c2d4b663eecd2dca3c78e78957ff9
Contents?: true
Size: 1.1 KB
Versions: 20
Compression:
Stored size: 1.1 KB
Contents
class String # Returns a random String of a given +length+. def self.random(length = 100) (0...length).map { ("a".."z").to_a[rand(26)] }.join end # Returns the String in snake_case. 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 # Returns the String in lowerCamelCase. 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 # Returns the String without namespace. def strip_namespace gsub /(.+:)(.+)/, '\2' end # Translates SOAP response values to more convenient Ruby Objects. def map_soap_response return DateTime.parse( self ) if Savon::SOAPDateTimeRegexp === self return true if self.strip.downcase == "true" return false if self.strip.downcase == "false" self end # Returns the String as a SOAP request compliant value. def to_soap_value to_s end end
Version data entries
20 entries across 20 versions & 4 rubygems