Class: Differ::Change

Inherits:
Object
  • Object
show all
Defined in:
lib/differ/change.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Change

Returns a new instance of Change.



4
5
6
7
# File 'lib/differ/change.rb', line 4

def initialize(options = {})
  @insert = options[:insert] || ''
  @delete = options[:delete] || ''
end

Instance Attribute Details

#deleteObject

Returns the value of attribute delete.



3
4
5
# File 'lib/differ/change.rb', line 3

def delete
  @delete
end

#insertObject

Returns the value of attribute insert.



3
4
5
# File 'lib/differ/change.rb', line 3

def insert
  @insert
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
# File 'lib/differ/change.rb', line 26

def ==(other)
  self.insert == other.insert && self.delete == other.delete
end

#change?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/differ/change.rb', line 17

def change?
  !@insert.empty? && !@delete.empty?
end

#delete?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/differ/change.rb', line 13

def delete?
  !@delete.empty?
end

#insert?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/differ/change.rb', line 9

def insert?
  !@insert.empty?
end

#to_sObject Also known as: inspect



21
22
23
# File 'lib/differ/change.rb', line 21

def to_s
  Differ.format.format(self)
end