Skip to content

Commit

Permalink
FEAT: Implemented sentence casing
Browse files Browse the repository at this point in the history
  • Loading branch information
janv8000 committed Jul 4, 2013
1 parent 49048bf commit cac0d71
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Humanizer/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static string FromPascalCase(string name)
return result.Replace(" i ", " I "); // I is an exception
}

public static string Humanize(this string input)
public static string Humanize(this string input)
{
// if input is all capitals (e.g. an acronym) then return it without change
if (!input.Any(Char.IsLower))
Expand All @@ -84,7 +84,7 @@ public static string Humanize(this string input)
return FromPascalCase(input);
}

public static string Humanize(this string input, LetterCasing casing)
public static string Humanize(this string input, LetterCasing casing)
{
var humanizedString = input.Humanize();

Expand All @@ -103,9 +103,13 @@ public static string ApplyCase(this string input, LetterCasing casing)

case LetterCasing.AllCaps:
return input.ToUpper();
}

return input;
case LetterCasing.Sentence:
return string.Concat(input.Substring(0, 1).ToUpper(), input.Substring(1));

default:
throw new ArgumentOutOfRangeException("casing");
}
}
}
}

0 comments on commit cac0d71

Please sign in to comment.