Class: TextAlignment::LCSAlignment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str1, str2, lcs = nil, sdiff = nil) ⇒ LCSAlignment

It initializes the LCS table for the given two strings, str1 and str2. Exception is raised when nil given passed to either str1, str2 or dictionary

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/text_alignment/lcs_alignment.rb', line 10

def initialize(str1, str2, lcs = nil, sdiff = nil)
	raise ArgumentError, "nil string" if str1 == nil || str2 == nil
	sdiff = TextAlignment::LCSMin.new(str1, str2).sdiff if sdiff.nil?
	_compute_position_map(str1, str2, sdiff)
end

Instance Attribute Details

#common_elementsObject (readonly)

Returns the value of attribute common_elements.



6
7
8
# File 'lib/text_alignment/lcs_alignment.rb', line 6

def common_elements
  @common_elements
end

#mapped_elementsObject (readonly)

Returns the value of attribute mapped_elements.



6
7
8
# File 'lib/text_alignment/lcs_alignment.rb', line 6

def mapped_elements
  @mapped_elements
end

#position_map_beginObject (readonly)

Returns the value of attribute position_map_begin.



5
6
7
# File 'lib/text_alignment/lcs_alignment.rb', line 5

def position_map_begin
  @position_map_begin
end

#position_map_endObject (readonly)

Returns the value of attribute position_map_end.



5
6
7
# File 'lib/text_alignment/lcs_alignment.rb', line 5

def position_map_end
  @position_map_end
end