Project

ncase

0.0
Repository is archived
Low commit activity in last 3 years
No release in over a year
Enforce a case style.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

<img src=“https://badge.fury.io/rb/ncase.svg” alt=“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"