class Handlebars::Helpers::CodeRuby::Demodulize

Demodulize: Removes the module part from the expression in the string.

Public Instance Methods

handlebars_helper() click to toggle source
# File lib/handlebars/helpers/code_ruby/demodulize.rb, line 52
def handlebars_helper
  proc { |_context, value| wrapper(parse(value)) }
end
parse(value) click to toggle source

Parse will demodulize, aka remove the module part from the expression in the string.

@example

puts Demodulize.new.parse('ActiveSupport::Inflector::Inflections')

Inflections

@example

demodulize('ActiveSupport::Inflector::Inflections') # => "Inflections"
demodulize('Inflections')                           # => "Inflections"
demodulize('::Inflections')                         # => "Inflections"
demodulize('')                                      # => ""

puts Demodulize.new.parse('Inflections')

Inflections

@example

puts Demodulize.new.parse('::Inflections')

Inflections

@example

puts Demodulize.new.parse('')

""
@param [String] value - name of the ruby module and class name separated by

@return [String] value demodulize, aka class name without module

# File lib/handlebars/helpers/code_ruby/demodulize.rb, line 46
def parse(value)
  return '' if value.nil?

  value.demodulize
end