Class: Vedeu::Editor::Lines Private
- Inherits:
-
Object
- Object
- Vedeu::Editor::Lines
- Extended by:
- Forwardable
- Includes:
- Enumerable, Collection
- Defined in:
- lib/vedeu/editor/lines.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 (also: #lines)
Instance Method Summary collapse
-
#delete_character(y, x) ⇒ Vedeu::Editor::Lines
private
Deletes the character from the line where the cursor is currently positioned.
-
#delete_line(index = nil) ⇒ String
private
Delete the line from the lines positioned at the given index.
-
#each(&block) ⇒ Enumerator
private
Provides iteration over the collection.
-
#initialize(collection = nil) ⇒ Vedeu::Editor::Lines
constructor
private
Returns a new instance of Vedeu::Editor::Lines.
-
#insert_character(character, y, x) ⇒ Vedeu::Editor::Lines
private
Insert a character in to a line.
-
#insert_line(index = nil) ⇒ Vedeu::Editor::Lines
private
Insert the line on the line below the given index.
-
#line(index = nil) ⇒ Vedeu::Editor::Line
private
Returns the line at the given index.
-
#to_s ⇒ String
(also: #to_str)
private
Return the lines as a string.
Methods included from Collection
Methods included from Repositories::Assemblage
#[], #any?, #empty?, #eql?, #size
Constructor Details
#initialize(collection = nil) ⇒ 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.
Returns a new instance of Vedeu::Editor::Lines.
34 35 36 |
# File 'lib/vedeu/editor/lines.rb', line 34 def initialize(collection = nil) @collection = collection || [] end |
Instance Attribute Details
#collection ⇒ String Also known as: lines
18 19 20 |
# File 'lib/vedeu/editor/lines.rb', line 18 def collection @collection end |
Instance Method Details
#delete_character(y, x) ⇒ 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.
Deletes the character from the line where the cursor is currently positioned.
44 45 46 47 48 |
# File 'lib/vedeu/editor/lines.rb', line 44 def delete_character(y, x) collection[y] = line(y).delete_character(x) unless line(y).empty? Vedeu::Editor::Lines.coerce(collection) end |
#delete_line(index = nil) ⇒ String
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.
Delete the line from the lines positioned at the given index.
54 55 56 57 |
# File 'lib/vedeu/editor/lines.rb', line 54 def delete_line(index = nil) Vedeu::Editor::Lines.coerce(Vedeu::Editor::Delete .from(lines, index, size)) end |
#each(&block) ⇒ Enumerator
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.
Provides iteration over the collection.
63 64 65 |
# File 'lib/vedeu/editor/lines.rb', line 63 def each(&block) collection.each(&block) end |
#insert_character(character, y, x) ⇒ 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.
Insert a character in to a line.
73 74 75 76 77 |
# File 'lib/vedeu/editor/lines.rb', line 73 def insert_character(character, y, x) collection[y] = line(y).insert_character(character, x) Vedeu::Editor::Lines.coerce(collection) end |
#insert_line(index = nil) ⇒ 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.
Insert the line on the line below the given index.
83 84 85 86 87 88 89 90 |
# File 'lib/vedeu/editor/lines.rb', line 83 def insert_line(index = nil) Vedeu::Editor::Lines.coerce( Vedeu::Editor::Insert.into(collection, Vedeu::Editor::Line.new, index, size) ) end |
#line(index = nil) ⇒ Vedeu::Editor::Line
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 the line at the given index.
96 97 98 99 100 101 |
# File 'lib/vedeu/editor/lines.rb', line 96 def line(index = nil) return Vedeu::Editor::Line.new unless collection return Vedeu::Editor::Line.coerce(collection[-1]) unless index Vedeu::Editor::Line.coerce(by_index(index)) end |
#to_s ⇒ String Also known as: to_str
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.
Return the lines as a string.
106 107 108 |
# File 'lib/vedeu/editor/lines.rb', line 106 def to_s collection.map(&:to_s).join end |