module SimpleSymbolize
Constants
- VERSION
Public Class Methods
translate() { |translations| ... }
click to toggle source
Configures the Symbolize environment.
@yieldparam [Translations] config the translations object yielded to the block.
# File lib/simple_symbolize.rb, line 21 def self.translate(&block) yield translations end
translations()
click to toggle source
Returns the translations object, initializing it if necessary.
@return [Translations] the translations object.
# File lib/simple_symbolize.rb, line 14 def self.translations @translations ||= Translations.new end
Public Instance Methods
symbolize(str)
click to toggle source
Symbolizes a String
object.
@param str [String] the String
object to be symbolized.
@example Symbolize a string using the symbolize method
symbolize("hello world!") #=> :hello_world
# File lib/simple_symbolize.rb, line 31 def symbolize(str) return str if str.is_a?(Symbol) || str.nil? str.downcase.tr(SimpleSymbolize.translations.underscore.join, '_') &.tr(SimpleSymbolize.translations.remove.join, '')&.to_sym end