Class: WordRunDiffLCS::WordRunContextChange

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(change_context) ⇒ WordRunContextChange

Returns a new instance of WordRunContextChange.



6
7
8
9
10
# File 'lib/word_run_diff_lcs.rb', line 6

def initialize(change_context)
  @action = change_context.action
  @old_element = change_context.old_element
  @new_element = change_context.new_element
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



4
5
6
# File 'lib/word_run_diff_lcs.rb', line 4

def action
  @action
end

#new_elementObject (readonly)

Returns the value of attribute new_element.



4
5
6
# File 'lib/word_run_diff_lcs.rb', line 4

def new_element
  @new_element
end

#old_elementObject (readonly)

Returns the value of attribute old_element.



4
5
6
# File 'lib/word_run_diff_lcs.rb', line 4

def old_element
  @old_element
end

Instance Method Details

#merge!(change_context) ⇒ Object



12
13
14
15
16
17
# File 'lib/word_run_diff_lcs.rb', line 12

def merge!(change_context)
  return false unless merge_possible_with?(change_context)
  @old_element << " #{change_context.old_element}" if change_context.old_element
  @new_element << " #{change_context.new_element}" if change_context.new_element
  true
end