Module: Rinne

Defined in:
lib/rinne.rb,
lib/rinne/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.camelize(spell) ⇒ Object Also known as: tensei



6
7
8
9
10
11
12
# File 'lib/rinne.rb', line 6

def camelize(spell)
  spell.split("-").map! {|module_word|
    module_word.split("_").map { |class_word|
      class_word.capitalize!
    }.join
  }.join("::")
end

.classify(path, filetype = "*") ⇒ Object



15
16
17
# File 'lib/rinne.rb', line 15

def classify(path, filetype = "*")
  camelize File.basename(path, ".#{filetype}")
end

.to_snake(str) ⇒ Object



19
20
21
22
23
24
# File 'lib/rinne.rb', line 19

def to_snake(str)
  str.gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-","_").downcase
end