Class: Vedeu::Editor::Insert Private
- Inherits:
-
Object
- Object
- Vedeu::Editor::Insert
- Includes:
- Common
- Defined in:
- lib/vedeu/editor/insert.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 ⇒ String|Vedeu::Editor::Line|Vedeu::Editor::Lines readonly private private
- #entity ⇒ String readonly protected private
- #index ⇒ Fixnum readonly protected private
- #size ⇒ Fixnum readonly protected private
Class Method Summary collapse
- .into(collection, entity, index = nil, size = 0) ⇒ String|Vedeu::Editor::Line|Vedeu::Editor::Lines private
Instance Method Summary collapse
- #index? ⇒ Boolean private private
-
#initialize(collection, entity, index = nil, size = 0) ⇒ Vedeu::Editor::Insert
constructor
private
Returns a new instance of Vedeu::Editor::Insert.
- #insert ⇒ String|Vedeu::Editor::Line|Vedeu::Editor::Lines private
- #position ⇒ Fixnum private private
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, entity, index = nil, size = 0) ⇒ Vedeu::Editor::Insert
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::Insert.
28 29 30 31 32 33 |
# File 'lib/vedeu/editor/insert.rb', line 28 def initialize(collection, entity, index = nil, size = 0) @collection = collection @entity = entity @index = index @size = size end |
Instance Attribute Details
#collection ⇒ String|Vedeu::Editor::Line|Vedeu::Editor::Lines (readonly, 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.
60 61 62 63 64 65 66 67 68 |
# File 'lib/vedeu/editor/insert.rb', line 60 def collection if string?(@collection) @collection.dup else @collection end end |
#entity ⇒ String (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.
46 47 48 |
# File 'lib/vedeu/editor/insert.rb', line 46 def entity @entity end |
#index ⇒ 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.
50 51 52 |
# File 'lib/vedeu/editor/insert.rb', line 50 def index @index 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.
54 55 56 |
# File 'lib/vedeu/editor/insert.rb', line 54 def size @size end |
Class Method Details
.into(collection, entity, index = nil, size = 0) ⇒ String|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/insert.rb', line 17 def self.into(collection, entity, index = nil, size = 0) new(collection, entity, index, size).insert end |
Instance Method Details
#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.
71 72 73 |
# File 'lib/vedeu/editor/insert.rb', line 71 def index? numeric?(index) end |
#insert ⇒ String|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.
36 37 38 39 40 |
# File 'lib/vedeu/editor/insert.rb', line 36 def insert return collection.insert(position, entity) if index? collection << entity end |
#position ⇒ 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.
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/vedeu/editor/insert.rb', line 76 def position if index < 0 0 elsif index > size size else index end end |