View Source Magma.Matter.Text (Magma v0.1.0)

Summary

Functions

Returns the text type module for the given string.

Returns the text type name for the given text module.

Types

@type t() :: %Magma.Matter.Text{name: term(), type: term()}
@type type() :: module()

Functions

@spec new(keyword()) :: {:ok, t()} | {:error, any()}
@spec new(type(), binary()) :: {:ok, t()} | {:error, any()}
Link to this function

sections_section_title()

View Source

Returns the text type module for the given string.

Example

iex> Magma.Matter.Text.type("UserGuide")
Magma.Matter.Texts.UserGuide

iex> Magma.Matter.Text.type("Generic")
Magma.Matter.Texts.Generic

iex> Magma.Matter.Text.type("Vault")
nil

iex> Magma.Matter.Text.type("NonExisting")
nil

Returns the text type name for the given text module.

Example

iex> Magma.Matter.Text.type_name(Magma.Matter.Texts.UserGuide)
"UserGuide"

iex> Magma.Matter.Text.type_name(Magma.Matter.Texts.Generic)
"Generic"

iex> Magma.Matter.Text.type_name(Magma.Vault)
** (RuntimeError) Invalid Magma.Matter.Text type: Magma.Vault

iex> Magma.Matter.Text.type_name(NonExisting)
** (RuntimeError) Invalid Magma.Matter.Text type: NonExisting