# `Ascii.Pieces.SplitFlap`
[🔗](https://github.com/houllette/ascii_art/blob/main/lib/ascii/pieces/split_flap.ex#L1)

A departures board whose flaps riffle to each new line.

An airport departures board. When a flight leaves, every row moves up and
each flap riffles through its drum, one card at a time, to land. Give it
your own departures: trains, buses, deploys, a queue.

## Options

Give them to `Ascii.new/2` as `options:`, and new ones while it plays
with `Ascii.put_options/2` (or a Phoenix player's `options`): the
board starts afresh with them, from its first board.

  * `title` - the board's heading, in upper case, spaced out, up to 18
    characters. Default `"departures"`.
  * `start` - the clock on the first board, `"HH:MM"`; after that the
    clock follows the departures. Not a time, and the first board's clock
    follows them too. Default `"14:03"`.
  * `flights` - the departures, in order, each `[time, destination, gate,
    remark]`: a time `"HH:MM"` (past midnight if it comes before the one
    above), a destination of up to 9 characters, a gate of up to 3, and a
    remark of up to 9. Flaps carry A to Z, 0 to 9 and `. - / ' &`; any
    other character shows a blank card. A remark of "on time", or none,
    turns to "gate open", "boarding" and "last call" as its time nears;
    any other ("delayed", "cancelled") stays. Six rows show; every six
    seconds the first leaves and the rest move up, the clock and remarks
    moving on between, and the list comes round again. A flight without a time is left out, and with none left
    the board plays upstream's. Default: twelve flights from 14:05.

The board is always 61 by 18.

## Colours

In one ink, or a gradient, with `:ink` and `:gradient` (see
`Ascii.Ink`); part by part with `:parts` (see `Ascii.Parts`),
`parts: true` taking the colours suggested here:

  * `frame` - the board's border, grey.
  * `title` - the heading.
  * `clock` - the clock at the top right, yellow.
  * `label` - the columns' headings, grey.
  * `time`, `destination`, `gate` - a flight's.
  * `remark`, and `remark.<text>` by what it says once its flaps are
    still, in lower case with runs of other characters as `_`:
    `remark.on_time` green, `remark.gate_open` and `remark.boarding`
    cyan, `remark.last_call` orange, `remark.delayed` yellow,
    `remark.cancelled` red, and a remark of the options' own, whole, as
    `remark.gate_closed` for "gate closed".
  * `flap` - the split beneath each flap, grey.
  * `flipping` - a flap mid-riffle, and the card falling over its split,
    yellow.

## Keys and clicks

It takes none: it is a board to read, and `Ascii.handle_event/2`
ignores every event. A Phoenix player given `interactive` and `notify`
still tells your LiveView where it was clicked, and on which part
(`Ascii.part_at/4`): a destination, say, and its text.

## Screen readers

`Ascii.describe/1` reads the title and clock, then the first three
flights, each its time, destination, gate and remark: "trains at 09:00:
09:10 berlin, gate a3; 09:25 madrid, gate b7, delayed; 09:40 rome, gate
c1, gate closed", with "and N more" after. Without flights, it says
"no flights".

## Example

```elixir
flights = [
  ["09:10", "berlin", "a3", ""],
  ["09:25", "madrid", "b7", "delayed"],
  ["09:40", "rome", "c1", "gate closed"]
]

board = Ascii.new!("split-flap", options: %{title: "trains", start: "09:00", flights: flights}, parts: true)
{frame, board} = Ascii.frame(board, 0.0)
frame.text =~ "B E R L I N"
#=> true

Ascii.describe(board)
#=> "trains at 09:00: 09:10 berlin, gate a3; 09:25 madrid, gate b7, delayed; 09:40 rome, gate c1, gate closed"
```

```heex
<Ascii.Phoenix.live_player id="board" piece="split-flap" options={%{title: "deploys", flights: @queue}} parts />
```

Ported from `src/pieces/split-flap.ts` in bas3line/ascii (MIT).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
