Class: Reenrb::Changes
- Inherits:
-
Object
- Object
- Reenrb::Changes
- Defined in:
- lib/reenrb/changes.rb
Overview
Change to an orignal file
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #accepted ⇒ Object
- #all_executed? ⇒ Boolean
- #any? ⇒ Boolean
- #change_requested ⇒ Object
- #changes_requested? ⇒ Boolean
- #count ⇒ Object
- #delete_requested ⇒ Object
- #execute_all ⇒ Object
- #executed ⇒ Object
- #failed ⇒ Object
-
#initialize(changes_list) ⇒ Changes
constructor
A new instance of Changes.
-
#no_changes_requested? ⇒ Boolean
Predicates.
- #rejected ⇒ Object
-
#rename_requested ⇒ Object
Queries.
-
#summarize ⇒ Object
Decoration.
Constructor Details
#initialize(changes_list) ⇒ Changes
Returns a new instance of Changes.
10 11 12 |
# File 'lib/reenrb/changes.rb', line 10 def initialize(changes_list) @list = changes_list end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
8 9 10 |
# File 'lib/reenrb/changes.rb', line 8 def list @list end |
Instance Method Details
#accepted ⇒ Object
37 38 39 |
# File 'lib/reenrb/changes.rb', line 37 def accepted Changes.new(@list.select(&:accepted?)) end |
#all_executed? ⇒ Boolean
75 76 77 |
# File 'lib/reenrb/changes.rb', line 75 def all_executed? @list.all?(&:executed?) end |
#any? ⇒ Boolean
49 50 51 |
# File 'lib/reenrb/changes.rb', line 49 def any? !@list.empty? end |
#change_requested ⇒ Object
29 30 31 |
# File 'lib/reenrb/changes.rb', line 29 def change_requested Changes.new(@list.reject(&:request_nothing?)) end |
#changes_requested? ⇒ Boolean
71 72 73 |
# File 'lib/reenrb/changes.rb', line 71 def changes_requested? !no_changes_requested? end |
#count ⇒ Object
53 54 55 |
# File 'lib/reenrb/changes.rb', line 53 def count @list.size end |
#delete_requested ⇒ Object
25 26 27 |
# File 'lib/reenrb/changes.rb', line 25 def delete_requested Changes.new(@list.select(&:request_delete?)) end |
#execute_all ⇒ Object
14 15 16 17 |
# File 'lib/reenrb/changes.rb', line 14 def execute_all @list.map(&:execute) self end |
#executed ⇒ Object
41 42 43 |
# File 'lib/reenrb/changes.rb', line 41 def executed Changes.new(@list.select(&:executed?)) end |
#failed ⇒ Object
45 46 47 |
# File 'lib/reenrb/changes.rb', line 45 def failed Changes.new(@list.select(&:failed?)) end |
#no_changes_requested? ⇒ Boolean
Predicates
67 68 69 |
# File 'lib/reenrb/changes.rb', line 67 def no_changes_requested? list.map(&:change).all? Change::CHANGE::NONE end |
#rejected ⇒ Object
33 34 35 |
# File 'lib/reenrb/changes.rb', line 33 def rejected Changes.new(@list.select(&:rejected?)) end |
#rename_requested ⇒ Object
Queries
21 22 23 |
# File 'lib/reenrb/changes.rb', line 21 def rename_requested Changes.new(@list.select(&:request_rename?)) end |
#summarize ⇒ Object
Decoration
59 60 61 62 63 |
# File 'lib/reenrb/changes.rb', line 59 def summarize return "Nothing changed" if @list.empty? @list.map(&:to_s).join("\n") end |