Class: Card::Content::Diff::Summary
- Defined in:
- card/lib/card/content/diff/summary.rb
Overview
Summary object for Diff processing
Instance Method Summary collapse
-
#add(text) ⇒ Object
-
#delete(text) ⇒ Object
-
#initialize(opts) ⇒ Summary
constructor
A new instance of Summary.
-
#omit ⇒ Object
-
#omits_content? ⇒ Boolean
-
#rendered ⇒ Object
Constructor Details
#initialize(opts) ⇒ Summary
Returns a new instance of Summary.
6 7 8 9 10 11 |
# File 'card/lib/card/content/diff/summary.rb', line 6 def initialize opts opts ||= {} @remaining_chars = opts[:length] || 50 @joint = opts[:joint] || "..." @chunks = [] end |
Instance Method Details
#add(text) ⇒ Object
17 18 19 |
# File 'card/lib/card/content/diff/summary.rb', line 17 def add text add_chunk text, :added end |
#delete(text) ⇒ Object
21 22 23 |
# File 'card/lib/card/content/diff/summary.rb', line 21 def delete text add_chunk text, :deleted end |
#omit ⇒ Object
25 26 27 28 29 |
# File 'card/lib/card/content/diff/summary.rb', line 25 def omit return unless @chunks.empty? || @chunks.last[:action] != :ellipsis add_chunk @joint, :ellipsis end |
#omits_content? ⇒ Boolean
31 32 33 |
# File 'card/lib/card/content/diff/summary.rb', line 31 def omits_content? @content_omitted || @remaining_chars.negative? end |
#rendered ⇒ Object
13 14 15 |
# File 'card/lib/card/content/diff/summary.rb', line 13 def rendered @rendered ||= render end |