Class: TextAlignment::LCSAlignment
- Inherits:
-
Object
- Object
- TextAlignment::LCSAlignment
- Defined in:
- lib/text_alignment/lcs_alignment.rb
Instance Attribute Summary collapse
-
#common_elements ⇒ Object
readonly
Returns the value of attribute common_elements.
-
#mapped_elements ⇒ Object
readonly
Returns the value of attribute mapped_elements.
-
#position_map_begin ⇒ Object
readonly
Returns the value of attribute position_map_begin.
-
#position_map_end ⇒ Object
readonly
Returns the value of attribute position_map_end.
Instance Method Summary collapse
-
#initialize(str1, str2, lcs = nil, sdiff = nil) ⇒ LCSAlignment
constructor
It initializes the LCS table for the given two strings, str1 and str2.
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
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_elements ⇒ Object (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_elements ⇒ Object (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_begin ⇒ Object (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_end ⇒ Object (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 |