Class: Lookout::Diff::Match
- Includes:
- Comparable
- Defined in:
- lib/lookout/diff/match.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #<=>(other) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(from, to) ⇒ Match
constructor
A new instance of Match.
- #inspect ⇒ Object
- #size ⇒ Object
- #touches?(other) ⇒ Boolean
Constructor Details
#initialize(from, to) ⇒ Match
Returns a new instance of Match.
6 7 8 |
# File 'lib/lookout/diff/match.rb', line 6 def initialize(from, to) @from, @to = from, to end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
35 36 37 |
# File 'lib/lookout/diff/match.rb', line 35 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
35 36 37 |
# File 'lib/lookout/diff/match.rb', line 35 def to @to end |
Instance Method Details
#+(other) ⇒ Object
18 19 20 |
# File 'lib/lookout/diff/match.rb', line 18 def +(other) self.class.new(from + other.from, to + other.to) end |
#<=>(other) ⇒ Object
26 27 28 29 |
# File 'lib/lookout/diff/match.rb', line 26 def <=>(other) [from.begin, from.end, to.begin, to.end] <=> [other.from.begin, other.from.end, other.to.begin, other.to.end] end |
#empty? ⇒ Boolean
10 11 12 |
# File 'lib/lookout/diff/match.rb', line 10 def empty? from.empty? end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/lookout/diff/match.rb', line 31 def inspect '#<%s %p==%p>' % [self.class, from, to] end |
#size ⇒ Object
14 15 16 |
# File 'lib/lookout/diff/match.rb', line 14 def size from.size end |
#touches?(other) ⇒ Boolean
22 23 24 |
# File 'lib/lookout/diff/match.rb', line 22 def touches?(other) from.end + 1 == other.from.begin and to.end + 1 == other.to.begin end |