Class: SuperDiff::Operations::BinaryOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/super_diff/operations/binary_operation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, left_collection:, right_collection:, left_index:, right_index:, left_key:, right_key:, left_value:, right_value:, child_operations: []) ⇒ BinaryOperation

Returns a new instance of BinaryOperation.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/super_diff/operations/binary_operation.rb', line 17

def initialize(
  name:,
  left_collection:,
  right_collection:,
  left_index:,
  right_index:,
  left_key:,
  right_key:,
  left_value:,
  right_value:,
  child_operations: []
)
  @name = name
  @left_collection = left_collection
  @right_collection = right_collection
  @left_index = left_index
  @right_index = right_index
  @left_key = left_key
  @right_key = right_key
  @left_value = left_value
  @right_value = right_value
  @child_operations = child_operations
end

Instance Attribute Details

#left_collectionObject (readonly)

Returns the value of attribute left_collection.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def left_collection
  @left_collection
end

#left_indexObject (readonly)

Returns the value of attribute left_index.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def left_index
  @left_index
end

#left_keyObject (readonly)

Returns the value of attribute left_key.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def left_key
  @left_key
end

#left_valueObject (readonly)

Returns the value of attribute left_value.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def left_value
  @left_value
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def name
  @name
end

#right_collectionObject (readonly)

Returns the value of attribute right_collection.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def right_collection
  @right_collection
end

#right_indexObject (readonly)

Returns the value of attribute right_index.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def right_index
  @right_index
end

#right_keyObject (readonly)

Returns the value of attribute right_key.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def right_key
  @right_key
end

#right_valueObject (readonly)

Returns the value of attribute right_value.



4
5
6
# File 'lib/super_diff/operations/binary_operation.rb', line 4

def right_value
  @right_value
end

Instance Method Details

#should_add_comma_after_displaying?Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/super_diff/operations/binary_operation.rb', line 41

def should_add_comma_after_displaying?
  left_index < left_collection.size - 1 ||
    right_index < right_collection.size - 1
end