Class: XDry::MultiIP
- Inherits:
-
InsertionPoint
- Object
- InsertionPoint
- XDry::MultiIP
- Defined in:
- lib/xdry/patching/insertion_points.rb
Instance Attribute Summary
Attributes inherited from InsertionPoint
Instance Method Summary collapse
- #find! ⇒ Object
-
#initialize(*insertion_points) ⇒ MultiIP
constructor
A new instance of MultiIP.
- #wrap(lines) ⇒ Object
- #wrap_if_last!(before, after) ⇒ Object
- #wrap_with_empty_lines_if_last! ⇒ Object
Methods inherited from InsertionPoint
Constructor Details
#initialize(*insertion_points) ⇒ MultiIP
Returns a new instance of MultiIP.
179 180 181 182 183 184 |
# File 'lib/xdry/patching/insertion_points.rb', line 179 def initialize *insertion_points @insertion_points = insertion_points @last_before = [] @last_after = [] super() end |
Instance Method Details
#find! ⇒ Object
195 196 197 |
# File 'lib/xdry/patching/insertion_points.rb', line 195 def find! @insertion_points.detect { |ip| try ip } end |
#wrap(lines) ⇒ Object
199 200 201 202 203 204 205 |
# File 'lib/xdry/patching/insertion_points.rb', line 199 def wrap lines if @ip == @insertion_points.last @last_before + lines + @last_after else lines end end |
#wrap_if_last!(before, after) ⇒ Object
186 187 188 189 |
# File 'lib/xdry/patching/insertion_points.rb', line 186 def wrap_if_last! before, after @last_before = before @last_after = after end |
#wrap_with_empty_lines_if_last! ⇒ Object
191 192 193 |
# File 'lib/xdry/patching/insertion_points.rb', line 191 def wrap_with_empty_lines_if_last! wrap_if_last! [""], [""] end |