Class: PromptWarden::CLI::CLIBuffer
- Inherits:
-
Object
- Object
- PromptWarden::CLI::CLIBuffer
- Defined in:
- lib/prompt_warden/cli.rb
Instance Method Summary collapse
-
#initialize ⇒ CLIBuffer
constructor
A new instance of CLIBuffer.
- #on_event(&block) ⇒ Object
- #push(event) ⇒ Object
- #recent_events(limit: 10) ⇒ Object
Constructor Details
#initialize ⇒ CLIBuffer
Returns a new instance of CLIBuffer.
62 63 64 65 |
# File 'lib/prompt_warden/cli.rb', line 62 def initialize @events = [] @listeners = [] end |
Instance Method Details
#on_event(&block) ⇒ Object
72 73 74 |
# File 'lib/prompt_warden/cli.rb', line 72 def on_event(&block) @listeners << block end |
#push(event) ⇒ Object
67 68 69 70 |
# File 'lib/prompt_warden/cli.rb', line 67 def push(event) @events << event @listeners.each { |listener| listener.call(event) } end |
#recent_events(limit: 10) ⇒ Object
76 77 78 |
# File 'lib/prompt_warden/cli.rb', line 76 def recent_events(limit: 10) @events.last(limit) end |