DarkMatter.Inflections (DarkMatter v1.1.4) View Source
General utils for working with case conversions.
Link to this section Summary
Types
Available inflection conversions
Functions
Returns the camel case version of the string
Returns the pascal case version of the string
Converts either an atom or string to an atom based on the conversion
.
Converts either an atom or string to a string based on the conversion
.
Returns the pascal case version of the string
Returns the upper case version of the string
Returns the humanized case version of the string
Returns the camel case version of the string
Returns the plural version of the string
Returns the singluar version of the string
Returns the titleize case version of the string
Returns the underscore version of the string
Link to this section Types
Specs
conversion() :: :camel | :human | :title | :pascal | :plural | :singular | :constant | :underscore | :absinthe_camel | :absinthe_pascal
Available inflection conversions
Link to this section Functions
Specs
Returns the camel case version of the string
Examples
iex> absinthe_camelize("foo_bar")
"fooBar"
iex> absinthe_camelize("foo")
"foo"
iex> absinthe_camelize("__foo_bar")
"__fooBar"
iex> absinthe_camelize("__foo")
"__foo"
iex> absinthe_camelize("_foo")
"_foo"
Specs
Returns the pascal case version of the string
Examples
iex> absinthe_pascalize("foo_bar")
"FooBar"
iex> absinthe_pascalize("foo")
"Foo"
iex> absinthe_pascalize("__foo_bar")
"__FooBar"
iex> absinthe_pascalize("__foo")
"__Foo"
iex> absinthe_pascalize("_foo")
"_Foo"
Specs
atom(atom() | String.t(), conversion() | [conversion(), ...]) :: atom()
Converts either an atom or string to an atom based on the conversion
.
Examples
iex> atom("_foo_bar123XYZ", :absinthe_camel)
:_fooBar123XYZ
iex> atom(:fooBarz___test, :camel)
:fooBarzTest
Specs
binary(atom() | String.t(), conversion() | [conversion(), ...]) :: String.t()
Converts either an atom or string to a string based on the conversion
.
Examples
iex> binary("_foo_bar123XYZ", :absinthe_pascal)
"_FooBar123XYZ"
iex> binary("_foo_bar123XYZ", :absinthe_camel)
"_fooBar123XYZ"
iex> binary(:fooBarz___TESTPDF, :pascal)
"FooBarzTestpdf"
iex> binary(:fooBarz___TESTPDF, :camel)
"fooBarzTestpdf"
iex> binary(:HTTP_PdfTEST, :underscore)
"http_pdf_test"
iex> binary("buses", :singular)
"bus"
iex> binary("business", :plural)
"businesses"
iex> binary("MerchantBusiness", [:plural, :underscore])
"merchant_businesses"
Specs
Returns the pascal case version of the string
Examples
iex> camelize("foo_bar")
"fooBar"
iex> camelize("foo")
"foo"
iex> camelize("__foo_bar")
"fooBar"
iex> camelize("__foo")
"foo"
iex> camelize("_foo")
"foo"
Specs
Returns the upper case version of the string
Examples
iex> constantize("foo_bar")
"FOO_BAR"
iex> constantize("foo")
"FOO"
iex> constantize("__foo_bar")
"FOO_BAR"
iex> constantize("__foo")
"FOO"
iex> constantize("_foo")
"FOO"
Specs
Returns the humanized case version of the string
Examples
iex> humanize("foo_bar")
"Foo bar"
iex> humanize("foo")
"Foo"
iex> humanize("__foo_bar")
" foo bar"
iex> humanize("__foo")
" foo"
iex> humanize("_foo")
" foo"
Specs
Returns the camel case version of the string
Examples
iex> pascalize("foo_bar")
"FooBar"
iex> pascalize("foo")
"Foo"
iex> pascalize("__foo_bar")
"FooBar"
iex> pascalize("__foo")
"Foo"
iex> pascalize("_foo")
"Foo"
Specs
Returns the plural version of the string
Examples
iex> pluralize("dog")
"dogs"
iex> pluralize("person")
"people"
Specs
Returns the singluar version of the string
Examples
With an uppercase first letter:
iex> singularize("dogs")
"dog"
iex> singularize("people")
"person"
Specs
Returns the titleize case version of the string
Examples
iex> titleize("foo_bar")
"Foo Bar"
iex> titleize("foo")
"Foo"
iex> titleize("__foo_bar")
"Foo Bar"
iex> titleize("__foo")
"Foo"
iex> titleize("_foo")
"Foo"
Specs
Returns the underscore version of the string
Examples
iex> underscore("UpperCamelCase")
"upper_camel_case"
iex> underscore("pascalCase")
"pascal_case"