Class: Lookout::Diff::Group
- Includes:
- Enumerable
- Defined in:
- lib/lookout-3.0/diff/group.rb
Overview
Instance Method Summary collapse
-
#<<(operation) ⇒ Object
Adds OPERATION to the receiver.
- #each ⇒ Object
-
#empty? ⇒ Boolean
True if the receiver doesn’t contain any operations.
-
#fold(context) ⇒ self
Folds the last operation, leaving CONTEXT elements of context.
-
#new ⇒ Slice
The slice of the new sequence between the first operation’s beginning and the last operation’s end.
-
#old ⇒ Slice
The slice of the old sequence between the first operation’s beginning and the last operation’s end.
-
#parity? ⇒ Boolean
True if the receiver contains one operation and that operation represents parity.
Instance Method Details
#<<(operation) ⇒ Object
Adds OPERATION to the receiver.
16 |
# File 'lib/lookout-3.0/diff/group.rb', line 16 def <<(operation) operations << operation; self end |
# {|operation| ... } ⇒ Object # ⇒ Enumerator<Operation>
37 38 39 40 41 |
# File 'lib/lookout-3.0/diff/group.rb', line 37 def each return enum_for(__method__) unless block_given? operations.each do |operation| yield operation end self end |
#empty? ⇒ Boolean
Returns True if the receiver doesn’t contain any operations.
11 |
# File 'lib/lookout-3.0/diff/group.rb', line 11 def empty?; operations.empty? end |
#fold(context) ⇒ self
Folds the last operation, leaving CONTEXT elements of context.
23 |
# File 'lib/lookout-3.0/diff/group.rb', line 23 def fold(context) operations[-1] = operations[-1] << context; self end |
#new ⇒ Slice
Returns The slice of the new sequence between the first operation’s beginning and the last operation’s end.
49 |
# File 'lib/lookout-3.0/diff/group.rb', line 49 def new; slice(:new) end |
#old ⇒ Slice
Returns The slice of the old sequence between the first operation’s beginning and the last operation’s end.
45 |
# File 'lib/lookout-3.0/diff/group.rb', line 45 def old; slice(:old) end |
#parity? ⇒ Boolean
Returns True if the receiver contains one operation and that operation represents parity.
27 28 29 |
# File 'lib/lookout-3.0/diff/group.rb', line 27 def parity? operations.size == 1 and operations.first.parity? end |