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.

Parameters:



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:

  • #Enumerator<Operation>

    Returns An Enumerator over the operations.

    Returns:

    • (Enumerator<Operation>)

      An Enumerator over the operations



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.

Returns:

  • (Boolean)

    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.

Parameters:

  • context (Integer)

Returns:

  • (self)


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

def fold(context) operations[-1] = operations[-1] << context; self end

#newSlice

Returns The slice of the new sequence between the first operation’s beginning and the last operation’s end.

Returns:

  • (Slice)

    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

#oldSlice

Returns The slice of the old sequence between the first operation’s beginning and the last operation’s end.

Returns:

  • (Slice)

    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.

Returns:

  • (Boolean)

    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