class Handlebars::Helpers::CodeRuby::Deconstantize

Deconstantize: Removes the rightmost segment from the constant expression in the string.

Public Instance Methods

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

Parse will deconstantize, remove the rightmost segment from the constant expression in the string.

@example

puts Deconstantize.new.parse('Net::HTTP')

Net

puts Deconstantize.new.parse('::Net::HTTP')

::Net

puts Deconstantize.new.parse('String')

""

puts Deconstantize.new.parse('::String')

""

@param [String] value - name of the ruby constant expression @return [String] return constant without rightmost segment

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

  value.deconstantize
end