Skip to content

Instantly share code, notes, and snippets.

@hitode909
Last active December 27, 2015 01:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitode909/7245173 to your computer and use it in GitHub Desktop.
Save hitode909/7245173 to your computer and use it in GitHub Desktop.
lookコマンドを使ってlower caseをcamel caseにするやつ
#! /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