Class: Reline::KillRing
- Inherits:
-
Object
- Object
- Reline::KillRing
- Defined in:
- lib/reline/kill_ring.rb
Defined Under Namespace
Modules: State Classes: RingBuffer, RingPoint
Instance Method Summary collapse
- #append(string, before_p = false) ⇒ Object
-
#initialize(max = 1024) ⇒ KillRing
constructor
A new instance of KillRing.
- #process ⇒ Object
- #yank ⇒ Object
- #yank_pop ⇒ Object
Constructor Details
#initialize(max = 1024) ⇒ KillRing
Returns a new instance of KillRing.
59 60 61 62 63 64 |
# File 'lib/reline/kill_ring.rb', line 59 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) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/reline/kill_ring.rb', line 66 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 |
#process ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/reline/kill_ring.rb', line 81 def process case @state when State::FRESH # nothing to do when State::CONTINUED @state = State::PROCESSED when State::PROCESSED @state = State::FRESH when State::YANK # nothing to do end end |