Class: Reline::KillRing
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Enumerable
|
|
Inherits: | Object |
Defined in: | lib/reline/kill_ring.rb |
Class Method Summary
- .new(max = 1024) ⇒ KillRing constructor
Instance Method Summary
Constructor Details
.new(max = 1024) ⇒ KillRing
# File 'lib/reline/kill_ring.rb', line 61
def initialize(max = 1024) @ring = RingBuffer.new(max) @ring_pointer = nil @buffer = nil @state = State::FRESH end
Instance Method Details
#append(string, before_p = false)
[ GitHub ]# File 'lib/reline/kill_ring.rb', line 68
def append(string, before_p = false) case @state when State::FRESH, State::YANK @ring << RingPoint.new(string) @state = State::CONTINUED when State::CONTINUED, State::PROCESSED if before_p @ring.head.str.prepend(string) else @ring.head.str.concat(string) end @state = State::CONTINUED end end
#each
[ GitHub ]# File 'lib/reline/kill_ring.rb', line 116
def each start = head = @ring.head loop do break if head.nil? yield head.str head = head.backward break if head == start end end