Class: Clogs::Clogs
- Inherits:
-
Object
- Object
- Clogs::Clogs
- Defined in:
- lib/clogs/drawables/text.rb
Class Method Summary collapse
-
.expand_text_items(items, style) ⇒ Object
text_items is an array of Strings and linkable IDs of TextDrawables.
Class Method Details
.expand_text_items(items, style) ⇒ Object
text_items is an array of Strings and linkable IDs of TextDrawables. Resolve it into a flat list of [text, style] pairs.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/clogs/drawables/text.rb', line 201 def (items, style) return [] if items.nil? # An item is either literal text or the linkable id of a nested text # drawable such as strong() or link(). Ids are not always Strings, so # ask the display service about anything that could be one. Array(items).flat_map do |item| peer = DisplayService.instance&.query_display_drawable_for(item, nil_ok: true) if peer.is_a?(TextDrawable) peer.runs(style) else [[item.to_s, style]] end end end |