Class: Lookout::Diff::Group

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/lookout-3.0/diff/group.rb

Overview

Ordered sequence of related Operations; type enumerated by Groups.

Instance Method Summary collapse

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>

Overloads:

  • # {|operation| ... } ⇒ Object

    Enumerates the operations.

    Yield Parameters:



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



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

#newSlice



49
# File 'lib/lookout-3.0/diff/group.rb', line 49

def new; slice(:new) end

#oldSlice



45
# File 'lib/lookout-3.0/diff/group.rb', line 45

def old; slice(:old) end

#parity?Boolean



27
28
29
# File 'lib/lookout-3.0/diff/group.rb', line 27

def parity?
  operations.size == 1 and operations.first.parity?
end