Class: Compose::EditProcessor
- Inherits:
-
Object
- Object
- Compose::EditProcessor
- Includes:
- Thor::Shell
- Defined in:
- lib/compose/edit_processor.rb
Constant Summary collapse
- HISTORY_FILE =
'compose_history.json'
Instance Attribute Summary collapse
-
#edits ⇒ Object
readonly
Returns the value of attribute edits.
Instance Method Summary collapse
-
#initialize(edits) ⇒ EditProcessor
constructor
A new instance of EditProcessor.
- #process_edits ⇒ Object
Constructor Details
#initialize(edits) ⇒ EditProcessor
Returns a new instance of EditProcessor.
16 17 18 19 |
# File 'lib/compose/edit_processor.rb', line 16 def initialize(edits) @edits = edits @confirmed_edits = [] end |
Instance Attribute Details
#edits ⇒ Object (readonly)
Returns the value of attribute edits.
14 15 16 |
# File 'lib/compose/edit_processor.rb', line 14 def edits @edits end |
Instance Method Details
#process_edits ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/compose/edit_processor.rb', line 21 def process_edits edits.each do |edit| if confirm_edit(edit[:edit]) @confirmed_edits << edit[:edit] end end if @confirmed_edits.any? if ask('Do you want to apply all confirmed edits? (y/n)') == 'y' apply_confirmed_edits else puts 'All changes discarded.' end else puts 'No edits were confirmed.' end end |