Last active
December 27, 2015 01:29
-
-
Save hitode909/7245173 to your computer and use it in GitHub Desktop.
lookコマンドを使ってlower caseをcamel caseにするやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
source = ARGV.first | |
dest = '' | |
def extract(word) | |
if `look #{word}`.split(/\n/).include? word | |
return word | |
end | |
if word.length > 0 | |
extract word[0...-1] | |
else | |
raise 'not found' | |
end | |
end | |
while source.length > 0 | |
word = extract source | |
dest += word.capitalize | |
source = source[word.length .. -1] | |
end | |
puts dest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment