module Kramdown::Utils
Utils Module¶ ↑
This module contains utility class/modules/methods that can be used by both parsers and converters.
Public Class Methods
camelize(name)
click to toggle source
Treat name
as if it were snake cased (e.g. snake_case
) and camelize it (e.g. SnakeCase).
# File lib/kramdown/utils.rb, line 25 def self.camelize(name) name.split('_').inject(+'') {|s, x| s << x[0..0].upcase << x[1..-1] } end
deep_const_get(str)
click to toggle source
# File lib/kramdown/utils.rb, line 38 def self.deep_const_get(str) ::Object.const_get(str) end
snake_case(name)
click to toggle source
Treat name
as if it were camelized (e.g. CamelizedName) and snake-case it (e.g. camelized_name).
# File lib/kramdown/utils.rb, line 30 def self.snake_case(name) name = name.dup name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') name.gsub!(/([a-z])([A-Z])/, '\1_\2') name.downcase! name end