ExUssd.Nav (ExUssd v1.1.0) View Source
USSD Nav module
Link to this section Summary
Link to this section Types
Link to this section Functions
Specs
new(keyword()) :: %ExUssd.Nav{ bottom: term(), delimiter: term(), left: term(), match: term(), name: term(), orientation: term(), reverse: term(), right: term(), show: term(), top: term(), type: term() }
Its used to create a new ExUssd Nav menu.
:type
- The type of the menu. ExUssd supports 3 types of nav- :home - Go back to the initial menu
- :back - Go back to the previous menu
- :next - Go to the nested menu
:name
- The name of the nav.:match
- The match string to match the nav. example when the user enters "0" for:back
type, the match string is "0":delimiter
- The delimiter to split the match string. default is ":":orientation
- The orientation of the nav. default is :horizontal:reverse
- Reverse the order of the nav. default is false:top
- Add top position padding of the nav. default is 0:bottom
- Add padding to bottom position of the nav. default is 0:right
- Add padding to right position of the nav. default is 0:left
- Add padding to left position of the nav. default is 0:show
- Show the nav. default is true. if false, the nav will not be shown in the menu
Example
iex> menu = ExUssd.new(name: "home")
iex> ExUssd.set(menu, nav: Nav.new(type: :next, name: "MORE", match: "98"))
iex> menu = ExUssd.new(name: "home")
iex> ExUssd.set(menu, nav: [
ExUssd.Nav.new(type: :home, name: "HOME", match: "00", reverse: true, orientation: :vertical)
ExUssd.Nav.new(type: :back, name: "BACK", match: "0", right: 1),
ExUssd.Nav.new(type: :next, name: "MORE", match: "98")
])
Specs
Convert the USSD navigation menu to string
Example
iex> Nav.new(type: :next, name: "MORE", match: "98") |> Nav.to_string()
"MORE:98"
iex> nav = [
ExUssd.Nav.new(type: :home, name: "HOME", match: "00", reverse: true, orientation: :vertical),
ExUssd.Nav.new(type: :back, name: "BACK", match: "0", right: 1),
ExUssd.Nav.new(type: :next, name: "MORE", match: "98")
]
iex> ExUssd.Nav.to_string(nav)
"HOME:00
BACK:0 MORE:98"
Link to this function