Class: Lookout::Diff::Group

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

Instance Method Summary collapse

Constructor Details

#initialize(*operations) ⇒ Group

Returns a new instance of Group.



6
7
8
# File 'lib/lookout/diff/group.rb', line 6

def initialize(*operations)
  @operations = operations
end

Instance Method Details

#<<(operation) ⇒ Object



14
15
16
17
# File 'lib/lookout/diff/group.rb', line 14

def <<(operation)
  operations << operation
  self
end

#==(other) ⇒ Object



43
44
45
# File 'lib/lookout/diff/group.rb', line 43

def ==(other)
  operations == other.operations
end

#eachObject



28
29
30
31
32
33
# File 'lib/lookout/diff/group.rb', line 28

def each
  operations.each do |operation|
    yield operation
  end
  self
end

#empty?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/lookout/diff/group.rb', line 10

def empty?
  operations.empty?
end

#fold(context) ⇒ Object



19
20
21
22
# File 'lib/lookout/diff/group.rb', line 19

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

#fromObject



35
36
37
# File 'lib/lookout/diff/group.rb', line 35

def from
  range(:from)
end

#inspectObject



47
48
49
# File 'lib/lookout/diff/group.rb', line 47

def inspect
  '<#%s %p>' % [self.class, operations]
end

#parity?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/lookout/diff/group.rb', line 24

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

#toObject



39
40
41
# File 'lib/lookout/diff/group.rb', line 39

def to
  range(:to)
end