Class: FixTSVConflict::Conflict
- Inherits:
-
Object
- Object
- FixTSVConflict::Conflict
- Defined in:
- lib/fix_tsv_conflict/conflict.rb
Constant Summary collapse
- ID_REGEXP =
/\A[0-9]+\t/- NL_REGEXP =
/\A\n/
Instance Attribute Summary collapse
-
#lbranch ⇒ Object
readonly
Returns the value of attribute lbranch.
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#rbranch ⇒ Object
readonly
Returns the value of attribute rbranch.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
-
#initialize(left, lbranch, right, rbranch) ⇒ Conflict
constructor
A new instance of Conflict.
- #to_a ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(left, lbranch, right, rbranch) ⇒ Conflict
5 6 7 8 9 10 |
# File 'lib/fix_tsv_conflict/conflict.rb', line 5 def initialize(left, lbranch, right, rbranch) @left = left @lbranch = lbranch @right = right @rbranch = rbranch end |
Instance Attribute Details
#lbranch ⇒ Object (readonly)
Returns the value of attribute lbranch.
3 4 5 |
# File 'lib/fix_tsv_conflict/conflict.rb', line 3 def lbranch @lbranch end |
#left ⇒ Object (readonly)
Returns the value of attribute left.
3 4 5 |
# File 'lib/fix_tsv_conflict/conflict.rb', line 3 def left @left end |
#rbranch ⇒ Object (readonly)
Returns the value of attribute rbranch.
3 4 5 |
# File 'lib/fix_tsv_conflict/conflict.rb', line 3 def rbranch @rbranch end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
3 4 5 |
# File 'lib/fix_tsv_conflict/conflict.rb', line 3 def right @right end |
Instance Method Details
#to_a ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/fix_tsv_conflict/conflict.rb', line 20 def to_a result = [] result << "#{LEFT} #{lbranch}\n" result += left result << "#{SEP}\n" result += right result << "#{RIGHT} #{rbranch}\n" result end |
#valid? ⇒ Boolean
15 16 17 18 |
# File 'lib/fix_tsv_conflict/conflict.rb', line 15 def valid? left.all? { |line| ID_REGEXP =~ line || NL_REGEXP =~ line} && right.all? { |line| ID_REGEXP =~ line || NL_REGEXP =~ line } end |