Class: Vedeu::Editor::Line Private
- Inherits:
-
Object
- Object
- Vedeu::Editor::Line
- Extended by:
- Common
- Includes:
- Collection
- Defined in:
- lib/vedeu/editor/line.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 a single line of an Vedeu::Editor::Document.
Instance Attribute Summary collapse
- #collection ⇒ String (also: #line, #to_s)
Class Method Summary collapse
-
.absent?(variable) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
.become(klass, attributes) ⇒ Class
extended
from Common
private
Converts one class into another.
-
.boolean(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the value was a boolean.
-
.boolean?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Boolean.
-
.coerce(collection) ⇒ Vedeu::Editor::Line
private
Coerce a line into a new instance of Vedeu::Editor::Line.
-
.escape?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
.falsy?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value should be considered false.
-
.hash?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
.line_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::Line.
-
.numeric?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
.present?(variable) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
.snake_case(klass) ⇒ String
extended
from Common
private
Converts a class name to a lowercase snake case string.
-
.stream_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
.string?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
.truthy?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value should be considered true.
-
.view_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::View.
Instance Method Summary collapse
-
#[](index) ⇒ void
included
from Repositories::Assemblage
private
Return an individual element or collection of elements (if the given index is a Range).
-
#any?(&block) ⇒ Boolean
included
from Repositories::Assemblage
private
Returns a boolean indicating whether the collection is not empty.
-
#by_index(index) ⇒ String
included
from Collection
private
Fetches an item from a collection.
-
#character(index = nil) ⇒ String|NilClass
private
Return the character at the given index.
-
#delete_character(index = nil) ⇒ String
private
Delete the character from the line positioned at the given index.
-
#each(&block) ⇒ Enumerator
included
from Repositories::Assemblage
private
Provides iteration over the collection.
-
#empty? ⇒ Boolean
included
from Repositories::Assemblage
private
Returns a boolean indicating whether the collection is empty.
-
#eql?(other) ⇒ Boolean
(also: #==)
included
from Repositories::Assemblage
private
An object is equal when its values are the same.
-
#initialize(collection = nil) ⇒ Vedeu::Editor::Line
constructor
private
Returns a new instance of Vedeu::Editor::Line.
-
#insert_character(character, index = nil) ⇒ Vedeu::Editor::Line
private
Insert the character on the line positioned at the given index.
-
#size ⇒ Fixnum
included
from Repositories::Assemblage
private
Return the size of the collection.
Constructor Details
#initialize(collection = 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 a new instance of Vedeu::Editor::Line.
42 43 44 |
# File 'lib/vedeu/editor/line.rb', line 42 def initialize(collection = nil) @collection = collection || '' end |
Instance Attribute Details
#collection ⇒ String Also known as: line, to_s
17 18 19 |
# File 'lib/vedeu/editor/line.rb', line 17 def collection @collection end |
Class Method Details
.absent?(variable) ⇒ Boolean Originally defined in module Common
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 a variable is nil or empty.
.become(klass, attributes) ⇒ Class Originally defined in module Common
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.
Converts one class into another.
.boolean(value) ⇒ Boolean Originally defined in module Common
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 the value was a boolean.
.boolean?(value) ⇒ Boolean Originally defined in module Common
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 value is a Boolean.
.coerce(collection) ⇒ 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.
Coerce a line into a new instance of Vedeu::Editor::Line.
29 30 31 32 33 34 |
# File 'lib/vedeu/editor/line.rb', line 29 def coerce(collection) return collection if collection.is_a?(self) return new(collection) if string?(collection) new end |
.escape?(value) ⇒ Boolean Originally defined in module Common
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 value is an escape sequence object (e.g. Vedeu::Cells::Escape.)
.falsy?(value) ⇒ Boolean Originally defined in module Common
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 value should be considered false.
.hash?(value) ⇒ Boolean Originally defined in module Common
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 value is a Hash.
.line_model? ⇒ Boolean Originally defined in module Common
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 the model is a Views::Line.
.numeric?(value) ⇒ Boolean Originally defined in module Common
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 value is a Fixnum.
.present?(variable) ⇒ Boolean Originally defined in module Common
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 a variable has a useful value.
.snake_case(klass) ⇒ String Originally defined in module Common
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.
Converts a class name to a lowercase snake case string.
.stream_model? ⇒ Boolean Originally defined in module Common
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 the model is a Views::Stream.
.string?(value) ⇒ Boolean Originally defined in module Common
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 value is a Fixnum.
.truthy?(value) ⇒ Boolean Originally defined in module Common
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 value should be considered true.
.view_model? ⇒ Boolean Originally defined in module Common
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 the model is a Views::View.
Instance Method Details
#[](index) ⇒ void Originally defined in module Repositories::Assemblage
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.
This method returns an undefined value.
Return an individual element or collection of elements (if the given index is a Range).
#any?(&block) ⇒ Boolean Originally defined in module Repositories::Assemblage
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 collection is not empty.
#by_index(index) ⇒ String Originally defined in module Collection
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.
Fetches an item from a collection.
#character(index = nil) ⇒ String|NilClass
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 character at the given index.
50 51 52 53 54 55 |
# File 'lib/vedeu/editor/line.rb', line 50 def character(index = nil) return '' if collection && collection.empty? return collection[-1] unless index by_index(index) end |
#delete_character(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 character from the line positioned at the given index.
62 63 64 65 |
# File 'lib/vedeu/editor/line.rb', line 62 def delete_character(index = nil) Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete .from(line, index, size)) end |
#each(&block) ⇒ Enumerator Originally defined in module Repositories::Assemblage
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.
#empty? ⇒ Boolean Originally defined in module Repositories::Assemblage
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 collection is empty.
#eql?(other) ⇒ Boolean Also known as: == Originally defined in module Repositories::Assemblage
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.
An object is equal when its values are the same.
#insert_character(character, 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.
Insert the character on the line positioned at the given index.
73 74 75 76 77 78 |
# File 'lib/vedeu/editor/line.rb', line 73 def insert_character(character, index = nil) return self unless character Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert .into(collection, character, index, size)) end |
#size ⇒ Fixnum Originally defined in module Repositories::Assemblage
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 size of the collection.