ncase

Enforce a case style.


Keywords
ruby, text-processing
License
ISC
Install
gem install ncase -v 0.2.0

Documentation

Gem Version

Installation

The usual.

gem install ncase

“Binary”

Enforces the chosen case style on a string and writes it to the standard output.

% ncase --pascal-case this is a test string
ThisIsATestString

% ncase --lower-case ThisIsATestString
this is a test string

By default, enforces the random case.

% ncase this is a test string
ThiS IS A tesT stRINg

If no string is specified, processes the standard input line by line.

% cat input.txt
ThisIsATestString
THIS_IS_ANOTHER_TEST_STRING
This is yet another test string

% ncase --snake-case <input.txt
this_is_a_test_string
this_is_another_test_string
this_is_yet_another_test_string

Library

(Conveniently) enforcing a case style

Module {Ncase} contains convenience methods for all supported case styles.

require "ncase"

p Ncase.pascal("this is a test string")  # => "ThisIsATestString"
p Ncase.upper_snake("ICannotReadThis")   # => "I_CANNOT_READ_THIS"

Enforcing multiple case styles

Class {Ncase::Words} implements efficient conversion of a string into multiple case styles.

require "ncase"

w = Ncase::Words.new("this is a test string")
p w.pascal_case       # => "ThisIsATestString"
p w.inver_title_case  # => "tTHIS iS a tEST sTRING"