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

Summary

Types

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

Functions

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

sections_section_title()

View Source
Link to this function

type(string, validate \\ true)

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
Link to this function

type_name(type, validate \\ true)

View Source

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