Class: SuperDiff::Operations::UnaryOperation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, collection:, key:, value:, index:, index_in_collection: index) ⇒ UnaryOperation

Returns a new instance of UnaryOperation.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/super_diff/operations/unary_operation.rb', line 14

def initialize(
  name:,
  collection:,
  key:,
  value:,
  # TODO: Is this even used??
  index:,
  index_in_collection: index
)
  @name = name
  @collection = collection
  @key = key
  @value = value
  # TODO: Is this even used??
  @index = index
  @index_in_collection = index_in_collection
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



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

def collection
  @collection
end

#indexObject (readonly)

Returns the value of attribute index.



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

def index
  @index
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#should_add_comma_after_displaying?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/super_diff/operations/unary_operation.rb', line 32

def should_add_comma_after_displaying?
  index_in_collection < collection.size - 1
end