Class: Reenrb::Changes

Inherits:
Object
  • Object
show all
Defined in:
lib/reenrb/changes.rb

Overview

Change to an orignal file

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#listObject (readonly)

Returns the value of attribute list.



8
9
10
# File 'lib/reenrb/changes.rb', line 8

def list
  @list
end

Instance Method Details

#acceptedObject



37
38
39
# File 'lib/reenrb/changes.rb', line 37

def accepted
  Changes.new(@list.select(&:accepted?))
end

#all_executed?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/reenrb/changes.rb', line 75

def all_executed?
  @list.all?(&:executed?)
end

#any?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/reenrb/changes.rb', line 49

def any?
  !@list.empty?
end

#change_requestedObject



29
30
31
# File 'lib/reenrb/changes.rb', line 29

def change_requested
  Changes.new(@list.reject(&:request_nothing?))
end

#changes_requested?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/reenrb/changes.rb', line 71

def changes_requested?
  !no_changes_requested?
end

#countObject



53
54
55
# File 'lib/reenrb/changes.rb', line 53

def count
  @list.size
end

#delete_requestedObject



25
26
27
# File 'lib/reenrb/changes.rb', line 25

def delete_requested
  Changes.new(@list.select(&:request_delete?))
end

#execute_allObject



14
15
16
17
# File 'lib/reenrb/changes.rb', line 14

def execute_all
  @list.map(&:execute)
  self
end

#executedObject



41
42
43
# File 'lib/reenrb/changes.rb', line 41

def executed
  Changes.new(@list.select(&:executed?))
end

#failedObject



45
46
47
# File 'lib/reenrb/changes.rb', line 45

def failed
  Changes.new(@list.select(&:failed?))
end

#no_changes_requested?Boolean

Predicates

Returns:

  • (Boolean)


67
68
69
# File 'lib/reenrb/changes.rb', line 67

def no_changes_requested?
  list.map(&:change).all? Change::CHANGE::NONE
end

#rejectedObject



33
34
35
# File 'lib/reenrb/changes.rb', line 33

def rejected
  Changes.new(@list.select(&:rejected?))
end

#rename_requestedObject

Queries



21
22
23
# File 'lib/reenrb/changes.rb', line 21

def rename_requested
  Changes.new(@list.select(&:request_rename?))
end

#summarizeObject

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