module WowzaRest::CoreExt::String::Inflections
Public Instance Methods
camelize()
click to toggle source
# File lib/wowza_rest/core_ext/string/inflections.rb, line 18 def camelize tr('-', '_') .gsub(/\b[A-Z]+/, &:downcase) .gsub(/_(.)/, &:upcase) .tr('_', '') end
underscore()
click to toggle source
its mainly used when converting json attrs to getters/setters methods wowza rest api responses sometimes have attributes that contains dots and this causes problems when trying to convert it to a method thats why i have to replace all dots with underscores
# File lib/wowza_rest/core_ext/string/inflections.rb, line 9 def underscore gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .tr('.', '_') .downcase end