Skip to content

A method used to convert a Ruby String into a grammatically correct heading

License

Notifications You must be signed in to change notification settings

vulcancreative/headingify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Headingify

A method used to convert a string into a heading. It extends the String class; currently only supporting the English language. Please contribute if you are adept in other languages utilizing articles, conjunctions, and prepositions.

Headingify is based off of grammatical rules set forth in The Chicago Manual of Style. ed. 16 pgf. 8.155.

Download and Installation

The latest version of Headingify can be installed with RubyGems:

$ [sudo] gem install headingify

Add this line to your application's Gemfile:

gem 'headingify', '~> 1.2.0'

Usage

To execute in standalone mode do the following:

$ headingify "a simple string, including the preposition 'with'."
  # A Simple String, including the Preposition 'with'.

To escape words in a string do the following:

$ headingify "folding of the \%CheY\% protein."
  # Folding of the CheY Protein.

Headingify works on the String class, and can also be used in code:

s = "a simple string, including the preposition 'with'.".headingify
title = "folding of the \%CheY\% protein."; title.headingify!

To check if a String has already been headingified:

s.headingify; s.headingified?
  # true

This is beneficial when a String may be headingified twice, where the initial String contained escaped content:

s = "using the \%PI\% constant to access the Float variable".headingify
  # "Using the PI Constant to Access the Float Variable"

# without safety (note the word "Pi" changes in case)
s.headingify
  # "Using the Pi Constant to Access the Float Variable"

# with safety (nothing is changed, if previously headingified)
s.headingify! unless s.headingified?
  # nil

# ...or more easily
s.headingify_safe # or #headingify_safe! for replacement
  # nil

# ...and we still have our initial String, ta-da!
puts s
  # "Using the PI Constant to Access the Float Variable"

License

Headingify is released under the MIT license

Contributing

Currently looking for help with i18n. If you have an adept knowledge of articles, conjunctions, prepositions, and grammatical syntax in non-English languages, you are encouraged to contribute.

About

A method used to convert a Ruby String into a grammatically correct heading

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages