Class: Eskimo::ASCII::HighlightColumn
- Defined in:
- gems/eskimo-ascii/lib/eskimo/ascii/components/highlight_column.rb
Overview
Highlight a particular character of a string with an ASCII arrow.
HighlightColumn.new(line: 0, column: 14) do
"- include: lol://wut.yml"
end
=> "- include: lol://wut.yml"
" ^ "
" here "
Instance Method Summary collapse
-
#initialize(column:, line:, markers: ['^', 'here'], style: [:bold, :red], &children) ⇒ HighlightColumn
constructor
A new instance of HighlightColumn.
- #render ⇒ Object
Constructor Details
#initialize(column:, line:, markers: ['^', 'here'], style: [:bold, :red], &children) ⇒ HighlightColumn
Returns a new instance of HighlightColumn
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'gems/eskimo-ascii/lib/eskimo/ascii/components/highlight_column.rb', line 11 def initialize( column:, line:, markers: ['^', 'here'], style: [:bold, :red], &children ) pastel = Pastel.new @colorize = ->(str) { pastel.decorate(str, *style) } @column = column @line = line @marker_padding = ' ' * @column @markers = markers super end |
Instance Method Details
#render ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'gems/eskimo-ascii/lib/eskimo/ascii/components/highlight_column.rb', line 29 def render(**) lines = super.lines line = lines[@line] unless line.nil? || line[@column].nil? lines[@line] = transform_line!(line, @column, &@colorize) end lines.join end |