Class: SuperDiff::OperationTrees::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, ImplementationChecks
Includes:
Enumerable, ImplementationChecks
Defined in:
lib/super_diff/operation_trees/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operations) ⇒ Base

Returns a new instance of Base.



17
18
19
# File 'lib/super_diff/operation_trees/base.rb', line 17

def initialize(operations)
  @operations = operations
end

Class Method Details

.applies_to?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/super_diff/operation_trees/base.rb', line 6

def self.applies_to?(*)
  unimplemented_class_method!
end

Instance Method Details

#flatten(indentation_level:) ⇒ Object



27
28
29
30
31
32
# File 'lib/super_diff/operation_trees/base.rb', line 27

def flatten(indentation_level:)
  operation_tree_flattener_class.call(
    self,
    indentation_level: indentation_level
  )
end

#perhaps_elide(tiered_lines) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/super_diff/operation_trees/base.rb', line 41

def perhaps_elide(tiered_lines)
  if SuperDiff.configuration.diff_elision_enabled?
    TieredLinesElider.call(tiered_lines)
  else
    tiered_lines
  end
end

#pretty_print(pp) ⇒ Object



34
35
36
37
38
39
# File 'lib/super_diff/operation_trees/base.rb', line 34

def pretty_print(pp)
  pp.group(1, "#<#{self.class.name} [", "]>") do
    pp.breakable
    pp.seplist(self) { |value| pp.pp value }
  end
end

#to_diff(indentation_level:) ⇒ Object



21
22
23
24
25
# File 'lib/super_diff/operation_trees/base.rb', line 21

def to_diff(indentation_level:)
  TieredLinesFormatter.call(
    perhaps_elide(flatten(indentation_level: indentation_level))
  )
end