2016/03/11
初めてのgem
キャメルケース,スネークケース,パスカルケースを相互に変換するgemを書きました.
書き方わからずに色々やってたら最初にリリースした分は盛大にバグってました.
とりあえずバグが取れたのでまたgemに.
一応 gem install case_converter
で入れられます.
使い方はこんな感じ
"camel_case".snake_to_camel # => "camelCase"
"string ca_mel_case string".snake_to_camel # => "string caMelCase string"
"pascal_case".snake_to_camel # => "pascalCase"
"string pas_cal_case string".snake_to_camel # => "string pasCalCase string"
"snakeCase".camel_to_snake # => "snake_case"
"foo snakeCase bar".camel_to_snake # => "foo snake_case bar"
"pascalCase".camel_to_pascal # => "PascalCase"
"foo pasCalCase bar".camel_to_snake # => "foo pas_cal_case bar"
"SnakeCase".pascal_to_snake # => "snake_case"
"foo SnaKeCase bar".pascal_to_snake # => "foo sna_ke_case bar"
"CamelCase".pascal_to_camel # => "camelCase"
"foo CaMelCase bar".pascal_to_camel # => "foo caMelCase bar"
初心者でもこれなら簡単に書ける!