struct

TermBuf::Unicode::Breaker

Inherits Struct < Value < Object

Decides where extended grapheme cluster boundaries fall, following the UAX #29 rules GB1 through GB999.

One instance walks one string. For each character in order, ask #boundary? whether a cluster boundary precedes it, then hand the same character to #consume to advance the state.

Constructors

new

A fresh breaker, positioned before the first character of a string.

Source

Instance methods

boundary?(char : Char) : Bool

Whether a cluster boundary falls immediately before char. ameba:disable Metrics/CyclomaticComplexity

Source
consume(char : Char) : Nil

Advances the state as though char had been added to the current cluster. Call exactly once per character, after #boundary?.

Source
consume_ascii

Advances the state for a printable ASCII character. Every code point in 0x20..0x7E has break class Other, conjunct class None, and no pictographic property, so none of the tables need consulting.

Source
prepend_pending?

Whether the character just consumed was a Prepend. That is the only way an ASCII character can join the cluster before it, so it is also the only case where the ASCII fast path in Unicode.each_grapheme is unsafe.

Source