A fluent builder for the text a Ussd.State renders back to the caller.
Build one with build/0 and grow it with the pipe operator:
Ussd.Menu.build()
|> Ussd.Menu.text("Welcome")
|> Ussd.Menu.line("Select an option")
|> Ussd.Menu.listing(["Airtime", "Data Bundle"])Implements String.Chars, so a menu can be interpolated or passed anywhere a
string is expected.
Summary
Functions
Appends another menu's content, or the menu built by a (menu -> menu) function.
Starts an empty menu.
Appends :io_lib.format/2-formatted text, e.g. format(menu, "Balance: ~s", ["GHS 10"]).
Appends text followed by a newline.
Appends times blank lines (default 1).
Appends a numbered listing of items.
Prepends another menu's content, or the menu built by a (menu -> menu) function.
Appends raw text with no trailing newline.
Appends key translated via the configured Gettext backend (see trans/4).
Types
@type t() :: %Ussd.Menu{content: String.t()}
Functions
Appends another menu's content, or the menu built by a (menu -> menu) function.
@spec build() :: t()
Starts an empty menu.
Appends :io_lib.format/2-formatted text, e.g. format(menu, "Balance: ~s", ["GHS 10"]).
Appends text followed by a newline.
@spec line_break(t(), pos_integer()) :: t()
Appends times blank lines (default 1).
@spec listing(t(), [String.Chars.t()], keyword()) :: t()
Appends a numbered listing of items.
Options:
:numbering-(index :: non_neg_integer() -> String.Chars.t()), defaults to&(&1 + 1):spacer- separates the number from the item, defaults to".":divider- separates items, defaults to"\n":page/:per_page- sliceitemsbefore rendering, like Laravel's paginated listings
Prepends another menu's content, or the menu built by a (menu -> menu) function.
Appends raw text with no trailing newline.
Appends key translated via the configured Gettext backend (see trans/4).
Like trans/4, but followed by a newline - the translated counterpart to line/2.