Class: Aio::Text::CompareDiff
- Inherits:
-
Object
- Object
- Aio::Text::CompareDiff
- Defined in:
- lib/aio/core/text/compare.rb
Instance Attribute Summary collapse
-
#cm1 ⇒ Object
cm1 = [ MatchStringInfo_A, MatchStringInfo_A, .. ].
-
#cm2 ⇒ Object
cm1 = [ MatchStringInfo_A, MatchStringInfo_A, .. ].
Instance Method Summary collapse
-
#<<(info) ⇒ Object
info #=> { :cm => :cm1, :e => [cmd, key, match_string_info] }.
-
#content ⇒ Object
文本.
-
#content_compare ⇒ Object
比较的文本.
-
#content_muster ⇒ Object
两个文本集合.
-
#initialize ⇒ CompareDiff
constructor
A new instance of CompareDiff.
- #lines ⇒ Object
- #lines_compare ⇒ Object
-
#lines_muster ⇒ Object
所有不同行的集合.
- #size ⇒ Object
Constructor Details
#initialize ⇒ CompareDiff
Returns a new instance of CompareDiff.
48 49 50 51 |
# File 'lib/aio/core/text/compare.rb', line 48 def initialize @cm1 = [] @cm2 = [] end |
Instance Attribute Details
#cm1 ⇒ Object
cm1 = [ MatchStringInfo_A, MatchStringInfo_A, .. ]
46 47 48 |
# File 'lib/aio/core/text/compare.rb', line 46 def cm1 @cm1 end |
#cm2 ⇒ Object
cm1 = [ MatchStringInfo_A, MatchStringInfo_A, .. ]
46 47 48 |
# File 'lib/aio/core/text/compare.rb', line 46 def cm2 @cm2 end |
Instance Method Details
#<<(info) ⇒ Object
info #=> { :cm => :cm1, :e => [cmd, key, match_string_info] }
54 55 56 57 58 59 60 61 |
# File 'lib/aio/core/text/compare.rb', line 54 def <<(info) case info[:cm] when :cm1 @cm1 << info[:e].pop when :cm2 @cm2 << info[:e].pop end end |
#content ⇒ Object
文本
69 70 71 72 |
# File 'lib/aio/core/text/compare.rb', line 69 def content return [""] if cm1.first.nil? cm1.first.content end |
#content_compare ⇒ Object
比较的文本
75 76 77 78 |
# File 'lib/aio/core/text/compare.rb', line 75 def content_compare return [""] if cm2.first.nil? cm2.first.content end |
#content_muster ⇒ Object
两个文本集合
64 65 66 |
# File 'lib/aio/core/text/compare.rb', line 64 def content_muster { cm1: content, cm2: compare_content } end |
#lines ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/aio/core/text/compare.rb', line 84 def lines res = [] cm1.each do |e| res << e.line end res.uniq end |
#lines_compare ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/aio/core/text/compare.rb', line 93 def lines_compare res = [] cm2.each do |e| res << e.line end res.uniq end |
#lines_muster ⇒ Object
所有不同行的集合
103 104 105 |
# File 'lib/aio/core/text/compare.rb', line 103 def lines_muster { cm1: lines, cm2: lines_compare } end |
#size ⇒ Object
80 81 82 |
# File 'lib/aio/core/text/compare.rb', line 80 def size cm1.size end |