Class: Card::Diff::DiffBuilder::LCS::Summary
Instance Method Summary collapse
- #add(text) ⇒ Object
- #delete(text) ⇒ Object
-
#initialize(opts) ⇒ Summary
constructor
A new instance of Summary.
- #omit ⇒ Object
- #result ⇒ Object
Constructor Details
#initialize(opts) ⇒ Summary
Returns a new instance of Summary.
329 330 331 332 333 334 335 336 |
# File 'lib/card/diff.rb', line 329 def initialize opts opts ||= {} @remaining_chars = opts[:length] || 50 @joint = opts[:joint] || '...' @summary = nil @chunks = [] end |
Instance Method Details
#add(text) ⇒ Object
342 343 344 |
# File 'lib/card/diff.rb', line 342 def add text add_chunk text, :added end |
#delete(text) ⇒ Object
346 347 348 |
# File 'lib/card/diff.rb', line 346 def delete text add_chunk text, :deleted end |
#omit ⇒ Object
350 351 352 353 354 |
# File 'lib/card/diff.rb', line 350 def omit if @chunks.empty? or @chunks.last[:action] != :ellipsis add_chunk @joint, :ellipsis end end |
#result ⇒ Object
338 339 340 |
# File 'lib/card/diff.rb', line 338 def result @summary ||= render_chunks end |