Class: Black::Diff::Line
- Inherits:
-
Object
- Object
- Black::Diff::Line
- Defined in:
- lib/black/diff.rb
Overview
Nicer line API for views
Instance Method Summary collapse
- #changed? ⇒ Boolean
- #content ⇒ Object
- #deletion? ⇒ Boolean
-
#initialize(line) ⇒ Line
constructor
A new instance of Line.
- #new_line_number ⇒ Object
- #old_line_number ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(line) ⇒ Line
Returns a new instance of Line.
108 109 110 |
# File 'lib/black/diff.rb', line 108 def initialize(line) @line = line end |
Instance Method Details
#changed? ⇒ Boolean
112 113 114 |
# File 'lib/black/diff.rb', line 112 def changed? ['addition', 'deletion'].include? @line['type'] end |
#content ⇒ Object
120 121 122 |
# File 'lib/black/diff.rb', line 120 def content @content ||= @line['content'].slice(/^.{1}/, @line['content'].length) end |
#deletion? ⇒ Boolean
116 117 118 |
# File 'lib/black/diff.rb', line 116 def deletion? type == 'deletion' end |
#new_line_number ⇒ Object
128 129 130 |
# File 'lib/black/diff.rb', line 128 def new_line_number type == 'deletion' ? nil : @line['new_line_number'] end |
#old_line_number ⇒ Object
132 133 134 |
# File 'lib/black/diff.rb', line 132 def old_line_number type == 'addition' ? nil : @line['old_line_number'] end |
#type ⇒ Object
124 125 126 |
# File 'lib/black/diff.rb', line 124 def type @line['type'] end |