module Kramdown::Utils
Utils Module¶ ↑
This module contains utility class/modules/methods that can be used by both parsers and converters.
Constants
- OrderedHash
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 26 def self.camelize(name) 27 name.split('_').inject('') {|s,x| s << x[0..0].upcase << x[1..-1] } 28 end
deep_const_get(str)
click to toggle source
# File lib/kramdown/utils.rb 39 def self.deep_const_get(str) 40 ::Object.const_get(str) 41 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 31 def self.snake_case(name) 32 name = name.dup 33 name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') 34 name.gsub!(/([a-z])([A-Z])/,'\1_\2') 35 name.downcase! 36 name 37 end