Class: Vedeu::Editor::Delete Private
- Inherits:
-
Object
- Object
- Vedeu::Editor::Delete
- Includes:
- Common
- Defined in:
- lib/vedeu/editor/delete.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Manipulate the lines of an Vedeu::Editor::Document.
Instance Attribute Summary collapse
- #collection ⇒ Vedeu::Editor::Line|Vedeu::Editor::Lines readonly protected private
- #size ⇒ Fixnum readonly protected private
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Vedeu::Editor::Line|Vedeu::Editor::Lines private
- #index ⇒ Fixnum private private
-
#initialize(collection, index = nil, size = 0) ⇒ Vedeu::Editor::Delete
constructor
private
Returns a new instance of Vedeu::Editor::Delete.
-
#line? ⇒ Boolean
private
private
If true, we are dealing with a Line object.
-
#lines? ⇒ Boolean
private
private
If true, we are dealing with a Lines collection.
-
#negative_index? ⇒ Boolean
private
private
Returns a boolean indicating whether the index was given or negative.
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Constructor Details
#initialize(collection, index = nil, size = 0) ⇒ Vedeu::Editor::Delete
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Editor::Delete.
27 28 29 30 31 |
# File 'lib/vedeu/editor/delete.rb', line 27 def initialize(collection, index = nil, size = 0) @collection = collection @index = index @size = size end |
Instance Attribute Details
#collection ⇒ Vedeu::Editor::Line|Vedeu::Editor::Lines (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 |
# File 'lib/vedeu/editor/delete.rb', line 45 def collection @collection end |
#size ⇒ Fixnum (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/vedeu/editor/delete.rb', line 49 def size @size end |
Class Method Details
.from(collection, index = nil, size = 0) ⇒ Vedeu::Editor::Line|Vedeu::Editor::Lines
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/vedeu/editor/delete.rb', line 17 def self.from(collection, index = nil, size = 0) new(collection, index, size).delete end |
Instance Method Details
#delete ⇒ Vedeu::Editor::Line|Vedeu::Editor::Lines
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 39 |
# File 'lib/vedeu/editor/delete.rb', line 34 def delete return collection if collection.empty? || negative_index? return collection.dup.tap { |c| c.slice!(index) } if index return collection.dup.tap(&:pop) if lines? return collection.chop if line? end |
#index ⇒ Fixnum (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 |
# File 'lib/vedeu/editor/delete.rb', line 54 def index return nil unless @index @index = size - 1 if @index > size @index end |
#line? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
If true, we are dealing with a Line object.
64 65 66 |
# File 'lib/vedeu/editor/delete.rb', line 64 def line? string?(collection) end |
#lines? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
If true, we are dealing with a Lines collection.
72 73 74 |
# File 'lib/vedeu/editor/delete.rb', line 72 def lines? array?(collection) end |
#negative_index? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the index was given or negative.
80 81 82 |
# File 'lib/vedeu/editor/delete.rb', line 80 def negative_index? index && index < 0 end |