Class: SuperDiff::Core::Line
- Inherits:
-
Object
- Object
- SuperDiff::Core::Line
- Defined in:
- lib/super_diff/core/line.rb
Constant Summary collapse
- ICONS =
{ delete: '-', insert: '+', noop: ' ' }.freeze
- COLORS =
{ insert: :actual, delete: :expected, noop: :plain }.freeze
Instance Method Summary collapse
- #as_elided ⇒ Object
- #clone_with(overrides = {}) ⇒ Object
- #closes_collection? ⇒ Boolean
- #color ⇒ Object
- #complete_bookend? ⇒ Boolean
- #icon ⇒ Object
- #opens_collection? ⇒ Boolean
- #prefixed_with(prefix) ⇒ Object
- #with_comma ⇒ Object
- #with_complete_bookend(complete_bookend) ⇒ Object
- #with_value_appended(suffix) ⇒ Object
- #with_value_prepended(prelude) ⇒ Object
Instance Method Details
#as_elided ⇒ Object
54 55 56 |
# File 'lib/super_diff/core/line.rb', line 54 def as_elided clone_with(elided: true) end |
#clone_with(overrides = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/super_diff/core/line.rb', line 27 def clone_with(overrides = {}) self.class.new( type: type, indentation_level: indentation_level, prefix: prefix, value: value, add_comma: add_comma?, children: children, elided: elided?, collection_bookend: collection_bookend, complete_bookend: complete_bookend, **overrides ) end |
#closes_collection? ⇒ Boolean
78 79 80 |
# File 'lib/super_diff/core/line.rb', line 78 def closes_collection? collection_bookend == :close end |
#color ⇒ Object
46 47 48 |
# File 'lib/super_diff/core/line.rb', line 46 def color COLORS.fetch(type) end |
#complete_bookend? ⇒ Boolean
82 83 84 |
# File 'lib/super_diff/core/line.rb', line 82 def complete_bookend? complete_bookend != nil end |
#icon ⇒ Object
42 43 44 |
# File 'lib/super_diff/core/line.rb', line 42 def icon ICONS.fetch(type) end |
#opens_collection? ⇒ Boolean
74 75 76 |
# File 'lib/super_diff/core/line.rb', line 74 def opens_collection? collection_bookend == :open end |
#prefixed_with(prefix) ⇒ Object
66 67 68 |
# File 'lib/super_diff/core/line.rb', line 66 def prefixed_with(prefix) clone_with(prefix: prefix + self.prefix) end |
#with_comma ⇒ Object
50 51 52 |
# File 'lib/super_diff/core/line.rb', line 50 def with_comma clone_with(add_comma: true) end |
#with_complete_bookend(complete_bookend) ⇒ Object
70 71 72 |
# File 'lib/super_diff/core/line.rb', line 70 def with_complete_bookend(complete_bookend) clone_with(complete_bookend: complete_bookend) end |
#with_value_appended(suffix) ⇒ Object
62 63 64 |
# File 'lib/super_diff/core/line.rb', line 62 def with_value_appended(suffix) clone_with(value: value + suffix) end |
#with_value_prepended(prelude) ⇒ Object
58 59 60 |
# File 'lib/super_diff/core/line.rb', line 58 def with_value_prepended(prelude) clone_with(value: prelude + value) end |