Class: Vedeu::Editor::Line Private

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • collection (String|NilClass) (defaults to: nil)


42
43
44
# File 'lib/vedeu/editor/line.rb', line 42

def initialize(collection = nil)
  @collection = collection || ''
end

Instance Attribute Details

#collectionString Also known as: line, to_s

Returns:

  • (String)


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.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

.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.

Parameters:

  • klass (Class)

    The class to become an instance of.

  • attributes (Hash)

    The attributes of klass.

Returns:

  • (Class)

    Returns a new instance of klass.

.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.

Parameters:

  • value (void)

Returns:

.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.

Parameters:

Returns:

.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.

Parameters:

Returns:



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.)

Returns:

.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.

Parameters:

  • value (void)

Returns:

.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.

Parameters:

  • value (Hash|void)

Returns:

.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.

Returns:

.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.

Parameters:

  • value (Fixnum|void)

Returns:

.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.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

.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.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

snake_case('MyClassName') # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

Parameters:

  • klass (Module|Class|String)

Returns:

  • (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.

Returns:

.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.

Parameters:

  • value (String|void)

Returns:

.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.

Parameters:

  • value (void)

Returns:

.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.

Returns:

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).

Parameters:

  • index (Fixnum|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.

Parameters:

  • block (Proc)

Returns:

#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.

Parameters:

  • index (Fixnum)

Returns:

  • (String)

#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.

Parameters:

  • index (Fixnum|NilClass) (defaults to: nil)

Returns:

  • (String|NilClass)


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.

Parameters:

  • index (Fixnum|NilClass) (defaults to: nil)

Returns:

  • (String)


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.

Parameters:

  • block (Proc)

Returns:

  • (Enumerator)

#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.

Returns:

#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.

Parameters:

  • other (void)

Returns:

#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.

Parameters:

  • character (String)
  • index (Fixnum|NilClass) (defaults to: nil)

Returns:



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

#sizeFixnum 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.

Returns:

  • (Fixnum)