Class: Consenter
- Inherits:
-
Object
- Object
- Consenter
- Defined in:
- lib/consenter.rb,
lib/consenter/version.rb
Overview
:nodoc:
Constant Summary collapse
- NAME =
'consenter'.freeze
- VERSION =
'1.0.6'.freeze
Instance Method Summary collapse
- #for(enumerable, &block) ⇒ Object
-
#initialize(prompt = '%s', options = {}) ⇒ Consenter
constructor
A new instance of Consenter.
Constructor Details
#initialize(prompt = '%s', options = {}) ⇒ Consenter
Returns a new instance of Consenter.
30 31 32 33 34 35 36 |
# File 'lib/consenter.rb', line 30 def initialize(prompt = '%s', = {}) @prompt = prompt + ' [' + ANSWERS + '] ' @inspector = .fetch(:inspector, :to_s) @no_to_all = .fetch(:none, false) @yes_to_all = .fetch(:all, false) end |
Instance Method Details
#for(enumerable, &block) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/consenter.rb', line 66 def for(enumerable, &block) enumerable.each do |arg| case arg when true then block.yield(arg) # user pressed 'y' or 'Y' when false then nil # user pressed 'n' or 'N' when nil then break # user pressed 'q' end end end |