Method: Textbringer::Buffer#substring
- Defined in:
- lib/textbringer/buffer.rb
#substring(s, e) ⇒ Object
462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/textbringer/buffer.rb', line 462 def substring(s, e) result = if s > @gap_start || e <= @gap_start @contents.byteslice(user_to_gap(s)...user_to_gap(e)) else len = @gap_start - s @contents.byteslice(user_to_gap(s), len) + @contents.byteslice(@gap_end, e - s - len) end if !@binary result.force_encoding(Encoding::UTF_8) end result end |